Draw

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rodrigo Ferreira

    #1

    Draw


    How can i draw a line inside a button?



  • darek

    #2
    Re: Draw

    Rodrigo Ferreira wrote:[color=blue]
    >
    > How can i draw a line inside a button?
    >
    >
    >[/color]

    this.button1.Pa int +=
    new System.Windows. Forms.PaintEven tHandler(this.b utton1_Paint);

    private void button1_Paint(o bject sender,
    System.Windows. Forms.PaintEven tArgs e)
    {
    e.Graphics.Draw Line(
    new System.Drawing. Pen(System.Draw ing.Color.Red), 0,0,10,10);
    }

    --
    darek

    Comment

    • Rodrigo Ferreira

      #3
      Re: Draw


      and inside a textbox?

      "darek" <mefist0@op.p l> wrote in message
      news:d89sem$is9 $1@nemesis.news .tpi.pl...[color=blue]
      > Rodrigo Ferreira wrote:[color=green]
      >> How can i draw a line inside a button?[/color]
      >
      > this.button1.Pa int +=
      > new System.Windows. Forms.PaintEven tHandler(this.b utton1_Paint);
      >
      > private void button1_Paint(o bject sender,
      > System.Windows. Forms.PaintEven tArgs e)
      > {
      > e.Graphics.Draw Line(
      > new System.Drawing. Pen(System.Draw ing.Color.Red), 0,0,10,10);
      > }
      >
      > --
      > darek
      >[/color]



      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: Draw

        Rodrigo,

        The same code would apply to the textbox. The Paint event would allow
        you to perform extra paint operations whenever the control was painted.

        Hope this helps.


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Rodrigo Ferreira" <rjrferreira@gm ail.com> wrote in message
        news:OTphsVRbFH A.3840@tk2msftn gp13.phx.gbl...[color=blue]
        >
        > and inside a textbox?
        >
        > "darek" <mefist0@op.p l> wrote in message
        > news:d89sem$is9 $1@nemesis.news .tpi.pl...[color=green]
        >> Rodrigo Ferreira wrote:[color=darkred]
        >>> How can i draw a line inside a button?[/color]
        >>
        >> this.button1.Pa int +=
        >> new System.Windows. Forms.PaintEven tHandler(this.b utton1_Paint);
        >>
        >> private void button1_Paint(o bject sender,
        >> System.Windows. Forms.PaintEven tArgs e)
        >> {
        >> e.Graphics.Draw Line(
        >> new System.Drawing. Pen(System.Draw ing.Color.Red), 0,0,10,10);
        >> }
        >>
        >> --
        >> darek
        >>[/color]
        >
        >
        >[/color]


        Comment

        • darek

          #5
          Re: Draw

          Nicholas Paldino [.NET/C# MVP] wrote:[color=blue]
          > Rodrigo,
          >
          > The same code would apply to the textbox. The Paint event would allow
          > you to perform extra paint operations whenever the control was painted.
          >
          > Hope this helps.[/color]

          Paint events dont fire up on textbox. If you want make textbox to do so,
          you have to use SetStyle method.

          public class MyTextBox : System.Windows. Forms.TextBox
          {
          public MyTextBox()
          {
          this.SetStyle(C ontrolStyles.Us erPaint, true);
          }

          protected override void OnPaint(PaintEv entArgs pe)
          {
          Graphics g = this.CreateGrap hics();
          g.DrawLine(
          new System.Drawing. Pen(System.Draw ing.Color.Red), 0,0,10,10);
          }
          }

          --
          darek

          Comment

          • Rodrigo Ferreira

            #6
            Re: Draw


            please you can be more explicit! I don't understand what you want to say!

            "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
            message news:%23qzMBnRb FHA.1660@tk2msf tngp13.phx.gbl. ..[color=blue]
            >
            > Rodrigo,
            >
            > The same code would apply to the textbox. The Paint event would allow
            > you to perform extra paint operations whenever the control was painted.
            >
            > Hope this helps.
            >
            >
            > --
            > - Nicholas Paldino [.NET/C# MVP]
            > - mvp@spam.guard. caspershouse.co m
            >
            > "Rodrigo Ferreira" <rjrferreira@gm ail.com> wrote in message
            > news:OTphsVRbFH A.3840@tk2msftn gp13.phx.gbl...[color=green]
            >>
            >> and inside a textbox?
            >>
            >> "darek" <mefist0@op.p l> wrote in message
            >> news:d89sem$is9 $1@nemesis.news .tpi.pl...[color=darkred]
            >>> Rodrigo Ferreira wrote:
            >>>> How can i draw a line inside a button?
            >>>
            >>> this.button1.Pa int +=
            >>> new System.Windows. Forms.PaintEven tHandler(this.b utton1_Paint);
            >>>
            >>> private void button1_Paint(o bject sender,
            >>> System.Windows. Forms.PaintEven tArgs e)
            >>> {
            >>> e.Graphics.Draw Line(
            >>> new System.Drawing. Pen(System.Draw ing.Color.Red), 0,0,10,10);
            >>> }
            >>>
            >>> --
            >>> darek
            >>>[/color]
            >>
            >>
            >>[/color]
            >
            >
            >[/color]



            Comment

            • Morten Wennevik

              #7
              Re: Draw

              All Controls have the Paint event. When Windows detects that a Control is in need of refreshing it will trigger the Paint event. You can add paint by subscribing to the PaintEventHandl er or in case of Controls like TextBoxes, override the Paint event in an inherited class.

              On Thu, 09 Jun 2005 19:52:51 +0200, Rodrigo Ferreira <rjrferreira@gm ail.com> wrote:
              [color=blue]
              >please you can be more explicit! I don't understand what you want to say!
              >
              > "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
              > message news:%23qzMBnRb FHA.1660@tk2msf tngp13.phx.gbl. ..[color=green]
              >>
              >> Rodrigo,
              >>
              >> The same code would apply to the textbox. The Paint event would allow
              >> you to perform extra paint operations whenever the control was painted.
              >>
              >> Hope this helps.
              >>
              >>
              >> --
              >> - Nicholas Paldino [.NET/C# MVP]
              >> - mvp@spam.guard. caspershouse.co m
              >>
              >> "Rodrigo Ferreira" <rjrferreira@gm ail.com> wrote in message
              >> news:OTphsVRbFH A.3840@tk2msftn gp13.phx.gbl...[color=darkred]
              >>>
              >>> and inside a textbox?
              >>>
              >>> "darek" <mefist0@op.p l> wrote in message
              >>> news:d89sem$is9 $1@nemesis.news .tpi.pl...
              >>>> Rodrigo Ferreira wrote:
              >>>>> How can i draw a line inside a button?
              >>>>
              >>>> this.button1.Pa int +=
              >>>> new System.Windows. Forms.PaintEven tHandler(this.b utton1_Paint);
              >>>>
              >>>> private void button1_Paint(o bject sender,
              >>>> System.Windows. Forms.PaintEven tArgs e)
              >>>> {
              >>>> e.Graphics.Draw Line(
              >>>> new System.Drawing. Pen(System.Draw ing.Color.Red), 0,0,10,10);
              >>>> }
              >>>>
              >>>> --
              >>>> darek
              >>>>
              >>>
              >>>
              >>>[/color]
              >>
              >>
              >>[/color]
              >
              >
              >
              >[/color]



              --
              Happy coding!
              Morten Wennevik [C# MVP]

              Comment

              Working...