DrawItem and MeasureItem

zy_abc

Regular
Joined
May 2, 2003
Messages
67
Visual Basic:
 Private Sub MenuItem0_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles MenuItem0.DrawItem
        Mn_DrawItem(e, MenuItem0.Text)
    End Sub

    Private Sub MenuItem0_MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles MenuItem0.MeasureItem
        Mn_MeasureItem(e, MenuItem0.Text)
    End Sub


Private Sub MenuItem1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles MenuItem1.DrawItem
        Mn_DrawItem(e, MenuItem1.Text)
    End Sub
    Private Sub MenuItem1_MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles MenuItem1.MeasureItem
        Mn_MeasureItem(e, MenuItem1.Text)
    End Sub

For each Menu Item i have to write code like this. If i delete the menu item then have to remove drawitem and measureitem for that menu. It is very tedious. Is there any easy way out. Any help will be appreciated.
 
You might find VolteFace's code here useful, it illustrates dynamically attaching event handlers and even painting menus like you're doing.
 
Back
Top