im having a little problem getting the item i select from my toolbar dropdown menu to do what i want it to do.
i want it to change the button text of the dropdownmenu to the selected item (in this case a font name)
here is my code
Code:Protected Sub toolBar1_ButtonDropDown(ByVal sender As Object, ByVal e As ToolBarButtonClickEventArgs) ' Evaluate the Button property of the ToolBarButtonClickEventArgs ' to determine which button was clicked. Select Case ToolBar1.Buttons.IndexOf(e.Button) Case 4 Dim docBox As RichTextBox = CType(ActiveControl, RichTextBox) Dim currentFont As System.Drawing.Font = docBox.SelectionFont Dim newFontStyle As System.Drawing.FontStyle 'below is whats is not working, i know its wrong, but 'i dont know what to put here. I need to get the font 'name that was selected from the list and change 'the .text property of button 4 to that font name. ToolBar1.Buttons(4).Text = fonts.MenuItems.IndexOf (fonts) docBox.SelectionFont = New Font(ToolBar1.Buttons(4).Text, currentFont.Size, newFontStyle) Case 5 End Select End Sub
this is in form_load
and this is public to the formCode:For Each ff In System.Drawing.FontFamily.Families Dim fontname As New MenuItem(ff.Name) fonts.MenuItems.Add(fontname) Next
if anyone can help with this i would very much appreciate it.Code:Dim fonts As New ContextMenu Dim fontsizes As New ContextMenu Dim ff As FontFamily


Reply With Quote