Click event on toolbar button - Winforms - c#

I have a user controls on winforms that contains a toolbar, the problem is whenever the application loses focus then i have to click the toolbar button twice to trigger the click event. I know this is because the first click is for the application to have the focus then then second click will be the actual click event. This only happens to toolbar control but not on other winforms controls.

I got tiered finding the right solution to solve this with ToolStrip control, what I did was I just changed it to Button control set its to Flatstyle then added some mouse hover to mimic the ToolStrip.

Related

Penal of User control going back side of parent panel

I have prepared one dropdown user control with a searching feature using textbox, panel, and checked listview.
when I click on down arrow PictureBox or in the displayed textbox, the listview panel will open as dropdown, and based on the mouse click I hiding and showing checked listview panel.
Now, when I put my user control within any panel and an open dropdown that time my user control's listview panel is going backside of the parent control/panel as I shown in the screen.
Please Help me.

WPF Prevent button from taking focus from any other control

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...

Scrolling focus with combo box Tab control in C# winapplication

After you click outside the drop down, it seems the focus is still on the drop down; scrolling, you select (without knowing) another value.
I want to lose the focus while clicking on the tab control or any location of the page.
As Otiel commented, click outside ComboBox won't make it lose the focus.
You can handle the Click event for the container (eg. a Panel) of your ComboBox and set the Focus to other control by using Control.Focus Method.

Windows Forms radio button click event is getting on start up

I have eight radio buttons on a user control. Each of them has or will have their own click handler. The first one has its click handler called when the user control is added to the main window. Is this normal behavior for Windows Forms (I am relatively new to .NET from a Java background)
This effect is likely the result of the default control selection rather than the control being added to the form. When the form finishes loading, one of the controls on the form will become the active control/have focus. If that control is a radio button, the button becomes checked, which will fire events like Click and CheckChanged (unless the radio button Checked property was already set to true). Depending on the Checked property value of the other buttons, you may see their CheckChanged events fire as well.
To test this out yourself, change the TabIndex property value in the designer so that some other control on the form will have the lowest index. This will make that control have focus on startup instead of the radio button(s). When this happens, you should not see the Click event being fired when the form is loaded.

How to detect context menu disappearance?

I need to make a control with popping out menu and button that causes it to be displayed and has changed (pressed) appearance during the time popped out menu is visible.
Currently i am using check box with Appearance property set to button and context menu. However detecting a moment when menu disappears from any reason other then click on one of its items (which generates Click event that can be handled) - for example, when the form is clicked - wasn't successful, as "Collapse" event didn't occur. As a result, "down-arrow button" didn't change its appearance back as intended.
How can disappearance of ContextMenu be detected? What are conditions for "Collapse" event to occur?
P.S. On related note, i was trying to implement the same thing with listbox set as top level window before; when form was clicked, it changed appearance but the loss of focus didn't occur. Any help with detecting the moment when it occurs would be greatly appreciated.
If you use the ContextMenuStrip you can handle the Closed event which is raised when the menu is closed.
"How can disappearance of ContextMenu be detected? What are conditions for "Collapse" event to occur?"
The Collapsed event is only raised of the ContextMenu is set as the ContextMenu of a control before you call Show

Categories

Resources