sub I use on all forms in my app I would like to put in one central place (of course right).
in vb.net
I put this sub in a module
it has a "Handles tabcontrol1.Drawitem" - I get an error saying handle requires with events variable defined in containing type or one of its base types.
also
when I refer to tabcontrol1 in a module it wants to know which form.. Can I use sender to define current calling form?
sub
in vb.net
I put this sub in a module
it has a "Handles tabcontrol1.Drawitem" - I get an error saying handle requires with events variable defined in containing type or one of its base types.
also
when I refer to tabcontrol1 in a module it wants to know which form.. Can I use sender to define current calling form?
sub
VB.NET:
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
Dim g As Graphics = e.Graphics
Dim tp As TabPage = [B]sender.[/B]TabControl1.TabPages(e.Index)
Dim br As Brush
Dim sf As New StringFormat
Dim r As New RectangleF(e.Bounds.X - 2, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height - 2)
sf.Alignment = StringAlignment.Center
Dim strTitle As String = tp.Text
'If the current index is the Selected Index, change the color
If sender.TabControl1.SelectedIndex = e.Index Then
'this is the background color of the tabpage
'you could make this a stndard color for the selected page
br = New SolidBrush(tp.BackColor)
'this is the background color of the tab page
g.FillRectangle(br, e.Bounds)
'this is the background color of the tab page
'you could make this a stndard color for the selected page
br = New SolidBrush(tp.ForeColor)
g.DrawString(strTitle, sender.TabControl1.Font, br, r, sf)
Else
'these are the standard colors for the unselected tab pages
br = New SolidBrush(Color.WhiteSmoke)
g.FillRectangle(br, e.Bounds)
br = New SolidBrush(Color.Black)
g.DrawString(strTitle, sender.TabControl1.Font, br, r, sf)
End If
End Sub