From: Darin on 6 Mar 2010 18:39 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 *** Sent via Developersdex http://www.developersdex.com ***
From: Cor Ligthert[MVP] on 7 Mar 2010 04:08 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 "Darin" <darin_nospam(a)nospamever> wrote in message news:uW8eFZYvKHA.5340(a)TK2MSFTNGP04.phx.gbl... > 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 > > *** Sent via Developersdex http://www.developersdex.com ***
From: Armin Zingler on 7 Mar 2010 07:21 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 -- Armin
|
Pages: 1 Prev: ASP.NET, Class Libraries, and HTTP Handlers Next: More multi threading advice needed! |