contextmenu

  • Thread starter Thread starter Darin
  • Start date Start date
D

Darin

i have a form with many textboxs. on a couple of textboxes, i have a
ContextMenu (not contextmenustrip, just contextmenu). When i right-click
the menu is displayed and all works fine. the issue is if my cursor is
on a different text box (say box 1) and the contextmenu is on box 4, and
with the cursor in box 1 (so that is where the focus is) they
right-click in box 4, the menu is displayed but focus hasn't actually
moved to box 4 - focus is still on box 1. How can i make it so when the
right-click on a text box is done, focus changes to that text box? Am i
missing a command on the click method or something?

Darin
 
Setting focus to a textbox is in the menu event Textbox4.focus, sorry I
don't see the problem you can have with that.

Be aware that not everybody wants the behaviour you want, so you have to do
things yourself.

Success

Cor
 
Am 07.03.2010 10:08, schrieb Cor Ligthert[MVP]:
Setting focus to a textbox is in the menu event Textbox4.focus, sorry I
don't see the problem you can have with that.

Be aware that not everybody wants the behaviour you want, so you have to do
things yourself.

Success

successful: ;-)

Dim cm As New ContextMenu
cm.MenuItems.Add("item 1")
cm.MenuItems.Add("item 2")
cm.MenuItems.Add("item many")
cm.MenuItems.Add("even more")

TextBox3.ContextMenu = cm
AddHandler cm.Popup, AddressOf OnCMPopup

'...

Sub OnCMPopup(ByVal sender As Object, ByVal e As System.EventArgs)
DirectCast(sender, ContextMenu).SourceControl.Select()
End Sub
 
Back
Top