I am trying to replicate an intellisense like feature where you have a textbox and a menu that's shown below it. I know intellisense doesn't use ContextMenuStrip, but my version has to have categories which are sub-menu items.
So as soon as the user clicks into my TextBox, I bring up the menu below once, but then even though I can see the caret in my TextBox it doesn't receive any key inputs. I have to click inside the TextBox again but that removes the menu from the screen.
Is there a way to prevent this? Or perhaps make the menu persistent on the screen without stealing focus?
ToolStrip control with items added to it seems to work since it's always on the form.
Related
I am fairly new to WPF and I need a little help on this one.
I have an application where I have an accountmanager, which enables the user to see all their accounts (by email) in a ListBox.
Is there a way I can add a button which can pop up a window,
on every listbox item (which holds an account each)?
The button should also be able to hide the window.
EDIT:
I have another way to make the window show, not by button, but by right-click instead. I was just wondering if someone had a quick answer.
Thanks in advance!
You could have a StackPanel as your listbox item and have it contain a Label for the account email string, and a Button that shows whatever window you want to show. You can set the StackPanel's orientation to fit your needs as well.
I have a simple ToolStrip with buttons in it which contain images and text. When I go over that button it changes appearance (same when it gets clicked). How can I customize this so that it stays highlighted when clicked? I have to do this over a tabControl so that it stays highlighted when the tab is entered and gets back to its normal appearance when leaving the tab. Which methods do I have to override?
Thank you!
just set ToolStripButton.CheckOnClick property to true from design time. So it will stay highlited when clicked.
About the other requirement set ToolStripButton.Checked to true on entring the tab control, and set it to false on leaving the tab control.
For entering and leaving you may use Control.Leave & Control.Enter events of tabpage/tabcontrol.
Let me know incase of any issues
I have an "On screen keypad" with some up/down/left/right/select buttons.
The select button is effectively a click and the arrow keys fire the associated up/down/left/right key.
The problem is that when selecting a combo box, I can't press the down/up buttons to navigate the items in the list. It is because the combo box auto closes when loosing focus. I can see similar problems happening with other controls, so I would like to see if there is a way to do the following.
For certain buttons (up/down/etc), when clicked, fire the click event, but don't take focus from w/e currently has the focus. This would allow the combox dropdown to stay open while pressing up/down to navigate through the items.
I have tried to set Focusable=False on the navigation buttons but the focus is still taken away from the combo box and the dropdown closes.
Any ideas/suggestions?
Thanks in advance
This isn't happening because of anything your Buttons are doing so changing their focus state won't make any difference. ComboBoxes close when you click anywhere outside of them, including empty space, non-interactive controls, other windows...
I have a note editor control in my Windows Forms application:
alt text http://img82.imageshack.us/img82/2033/tabtohiddencontrol.png
I want to make this control accessible through the keyboard: I want to be able to TAB to it, TAB through the controls, and TAB out of it.
Normally this is an easy task, however, the issue is the hidden subject textbox. By design, the subject is editable only when the user clicks on the subject label.
When my control receives focus, I want to start editing the subject; make the subject text box visible and focused.
WinForms doesn't like this; my subject text box is hidden, and so WinForms skips over it when tabbing in and out of my control. How can I make this work?
You will have to add code in previous code's lostfocus (or keypress to check for TAB). And, you will have to add code in next control (after the label textbox) to check for Shift+TAB.
You could also add a label before Subject with mnemonic, so user can press ALT+S to reach there.
This is what I could think of right away.
Correct me, if I have not understood your question.
When the user clicks on the subject label, unhide the subject textbox and set the focus to it.
Controls must be visible and enabled to be part of the tab order; you cannot tab into a control that is invisible or disabled.
I am adding a label to a form dynamically, then dynamically adding a ContextMenuStrip control. Whether I use the label.ContextMenuStrip property to connect them, or add the event handler to the label manually to have it respond to the right-click and show the context menu, I get odd behavior:
1) The menu does not appear next to the mouse pointer, it is offset down and to the right. It appears that it is related to the position of the label in it's parent control (a picture control), rather than the form.
2) The menu does not disappear when I click on something other than the menu.
Any ideas what I am missing here?
Thanks,
Andy
I worked it out. First off, I was adding the control to the label control collection, changing it to the the form collection corrected the positioning problem. I never did figure out why the menu would not close.
Ultimately I restructured things by adding a static instance of the menu to the form, then just connected the label.ContextMenuStrip property to that stastic instance. All is well with that approach.
I used the tag of the label control to identify it to the click event handler.