G
GatorBait
Good morning experts,
Here is what I'm trying to accomplish:
I have a form that has 8 panels spaced out so that they look like rows.
Inside each panel is a series of labels and when a user clicks any
label in the panel I am trying to have a thick border around the panel
to indicate that row has been selected. I was able to get it so that a
rectangle is drawn around the panel, but this is the problem I'm
running into. I have a modular level variable which I set to 0 or 3
for the selected row. I call the invalidate event of each panel so
that it will repaint. My problem is that I all of the rows are being
selected. Below is the code I am using (sorry the last Sub is ugly
looking):
Private Sub SelectRow(ByVal iRow As Integer, ByVal bSelected as
Boolean)
Dim x As Integer
'unselect all rows
m_iSize = 0
For x = 1 To 8
Me.Controls("pnlRow0" & CStr(x)).Invalidate()
Next
'draw border around selected border
If bSelected Then
m_iSize = 3
Me.Controls("pnlRow0" & CStr(iRow)).Invalidate()
End If
End Sub
Private Sub PaintBorder01(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles pnlRow01.Paint,
pnlRow02.Paint, pnlRow03.Paint, pnlRow04.Paint, pnlRow05.Paint,
pnlRow06.Paint, pnlRow07.Paint, pnlRow08.Paint
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle,
Color.Black, m_iSize, ButtonBorderStyle.Solid, Color.Black, m_iSize,
ButtonBorderStyle.Solid, Color.Black, m_iSize, ButtonBorderStyle.Solid,
Color.Black, m_iSize, ButtonBorderStyle.Solid)
End Sub
Here is what I'm trying to accomplish:
I have a form that has 8 panels spaced out so that they look like rows.
Inside each panel is a series of labels and when a user clicks any
label in the panel I am trying to have a thick border around the panel
to indicate that row has been selected. I was able to get it so that a
rectangle is drawn around the panel, but this is the problem I'm
running into. I have a modular level variable which I set to 0 or 3
for the selected row. I call the invalidate event of each panel so
that it will repaint. My problem is that I all of the rows are being
selected. Below is the code I am using (sorry the last Sub is ugly
looking):
Private Sub SelectRow(ByVal iRow As Integer, ByVal bSelected as
Boolean)
Dim x As Integer
'unselect all rows
m_iSize = 0
For x = 1 To 8
Me.Controls("pnlRow0" & CStr(x)).Invalidate()
Next
'draw border around selected border
If bSelected Then
m_iSize = 3
Me.Controls("pnlRow0" & CStr(iRow)).Invalidate()
End If
End Sub
Private Sub PaintBorder01(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles pnlRow01.Paint,
pnlRow02.Paint, pnlRow03.Paint, pnlRow04.Paint, pnlRow05.Paint,
pnlRow06.Paint, pnlRow07.Paint, pnlRow08.Paint
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle,
Color.Black, m_iSize, ButtonBorderStyle.Solid, Color.Black, m_iSize,
ButtonBorderStyle.Solid, Color.Black, m_iSize, ButtonBorderStyle.Solid,
Color.Black, m_iSize, ButtonBorderStyle.Solid)
End Sub