gchq
Well-known member
- Joined
- Dec 14, 2007
- Messages
- 168
- Programming Experience
- 10+
Hi there
I have a ContextMenuStrip attached to a TextBox
..and the click event
Whilst the form is loaded this runs fine twice, but then although the Setting boolean is reset the ToolStripItem text remains unchanged unless the form is re-loaded.
Any ideas why?
Thanks
I have a ContextMenuStrip attached to a TextBox
VB.NET:
Dim TelTBMenu As New ContextMenuStrip
With TelTBMenu
.Name = "TelTBMenu"
End With
Dim TelTBItem As ToolStripItem
Dim TelTBItemText As String = ""
If My.Settings.EnableIntTelNumbers = True Then
TelTBItemText = "Disable International Formatting"
Else
TelTBItemText = "Enable International Formatting"
End If
TelTBItem = TelTBMenu.Items.Add(TelTBItemText)
AddHandler TelTBItem.Click, AddressOf SuppliersTelephoneNumberReformat
With TelTB
.Name = "TelTB"
.Size = New Point(100, 20)
.Location = New Point(130, 230)
.ContextMenuStrip = TelTBMenu
End With
vBDPanel.Controls.Add(TelTB)
..and the click event
VB.NET:
Private Sub SuppliersTelephoneNumberReformat(ByVal sender As Object, ByVal e As EventArgs)
Dim TelTB As TextBox = RFC(SuppliersMainForm, "TelTB")
Dim TelTBmenu As ContextMenuStrip = TelTB.ContextMenuStrip
Dim TelTBItem As ToolStripItem '= TelTBmenu.Items("TelTBItem")
TelTBmenu.Items.Clear()
Dim TelTBItemText As String = ""
If My.Settings.EnableIntTelNumbers = False Then
TelTBItemText = "Disable International Formatting"
My.Settings.EnableIntTelNumbers = True
Else
TelTBItemText = "Enable International Formatting"
My.Settings.EnableIntTelNumbers = False
End If
TelTBItem = TelTBmenu.Items.Add(TelTBItemText)
My.Settings.Save()
End Sub
Whilst the form is loaded this runs fine twice, but then although the Setting boolean is reset the ToolStripItem text remains unchanged unless the form is re-loaded.
Any ideas why?
Thanks