Jump to content
Xtreme .Net Talk

Recommended Posts

  • Administrators
Posted

Easiest way would probably be to call .CreateGraphics on the button and then draw onto this - something like

 

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

Dim g As Graphics = Button1.CreateGraphics
g.DrawLine(Pens.Red, 0, 0, Button1.ClientRectangle.Width, Button1.ClientRectangle.Height)
g.DrawLine(Pens.Red, Button1.ClientRectangle.Width, 0, 0, Button1.ClientRectangle.Height)
g.Dispose()

End Sub

should do the trick.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Handle button Paint event

 

Ideally you'd use the button's Paint event:

 

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

   'Attach to Paint event
   AddHandler myButton.Paint, AddressOf DrawButton

End Sub

'Handle the event
Private Sub DrawButton(ByVal sender As Object, ByVal e As PaintEventArgs)

   'Draw cross
   e.Graphics.DrawLine(Pens.Red, 0, 0, myButton.ClientRectangle.Width, myButton.ClientRectangle.Height)
   e.Graphics.DrawLine(Pens.Red, myButton.ClientRectangle.Width, 0, 0, myButton.ClientRectangle.Height)
   'Dispose not required

End Sub

 

Good luck :cool:

Never trouble another for what you can do for yourself.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...