R
Rlrcstr
Trying to place a few radio buttons where I draw the image on the button. I declare an array of three buttons and initialize them as below. The paint event is getting triggered for the buttons, but my drawing never shows up. What am I doing wrong? Thanks.
For x As Integer = 0 To 2
drawStyle(x) = New RadioButton
With drawStyle(x)
.Width = pnlPalette.Width - 4
.Height = 24
.Appearance = Appearance.Button
.FlatStyle = FlatStyle.Popup
.Left = 2
.Tag = x
End With
pnlPalette.Controls.Add(drawStyle(x))
AddHandler drawStyle(x).Paint, AddressOf drawStyle_Paint
Next
---------------------------
Private Sub drawStyle_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
Dim r As RadioButton = sender
Dim g As Graphics = r.CreateGraphics()
With r
If (.Tag = "One") Then g.FillRectangle(New SolidBrush(_fillColor), 2, 2, .Width - 4, .Height - 4)
If (.Tag = "Two") Then g.DrawRectangle(New Pen(_lineColor, _lineWidth), 2, 2, .Width - 4, .Height - 4)
End With
End Sub
For x As Integer = 0 To 2
drawStyle(x) = New RadioButton
With drawStyle(x)
.Width = pnlPalette.Width - 4
.Height = 24
.Appearance = Appearance.Button
.FlatStyle = FlatStyle.Popup
.Left = 2
.Tag = x
End With
pnlPalette.Controls.Add(drawStyle(x))
AddHandler drawStyle(x).Paint, AddressOf drawStyle_Paint
Next
---------------------------
Private Sub drawStyle_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
Dim r As RadioButton = sender
Dim g As Graphics = r.CreateGraphics()
With r
If (.Tag = "One") Then g.FillRectangle(New SolidBrush(_fillColor), 2, 2, .Width - 4, .Height - 4)
If (.Tag = "Two") Then g.DrawRectangle(New Pen(_lineColor, _lineWidth), 2, 2, .Width - 4, .Height - 4)
End With
End Sub