Tabbing to invisible control in WinForms - c#

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.

Related

Make a ToolStrip Button staying highlighted when clicked in C#

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

Caret moves to the beginning of textbox when tooltip is displayed

One of our customers showed me the problem described in subject. Every textbox in our application has a tooltip: when the control is selected, user starts typing; shortly after, tooltip is displayed if user leaves the cursor over the control. At the same moment, caret is moved at the beginning of texbox control, so if the user is typing, say "hello world" it comes up with something like "rldhello wo".
I'm using a custom UserControl. Tooltip is dropped on UserControl along with a Texbox and its value is set when the UserControl is loaded and when undelying property content for Textbox changes by the following code:
myTooltip.ToolTipTitle = title;
myTooltip.SetToolTip(myTextbox, content);
When user types, undelying property displayed in Texbox is updated, causing the refresh.
Do you have any experience or suggestion about this issue?

How to prevent menu (ContextMenuStrip) to steal focus from my TextBox control?

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.

WinForms tooltip flips over when tab key is pressed

I have a balloon tooltip control on a form. If the user enters incorrect information then the tooltip is displayed. The problem is if you display the tool tip and then hit the tab button the tooltip 'flips' over, is there any way to stop this behavior?
Seems to be standard behavior, was able to fix it using a var and testing to see if it was displayed already.

how to lose control from text box when clicked outside

I have a textbox in a windows form. Currently the focus is on the textbox and i enter some text. Now I click outside the textbox but within the window. This action does not make the text box to lose the focus. The cursor still blinks in the text box. If the click was on another control then the text box would lose the control.
How would I make the text box to lose control when clicked outside of it (not just on another control but anywhere inside the form)?
Thanks in advance.
Datte
Because you click on a control that has no ability of taking the focus (like a form, a label, etc). If you click for instance on another text box the focus should move..
To move the focus programmatically (i.e. in the OnClick event of the Form) use the control.Focus method.

Categories

Resources