Acessing the click event for a customized control - c#

I made a customized control that is a picturebox and a button. When the user clicks on the button, i want to show a form that will capture the webcam image and put on the picturebox of the customized control. But i can access outside the control, the button click. I can access the control click but not only the button click...anyone can help me?
thanks!
Rafael

In your control's constructor after the InitializeComponent() (if you have it), write
this.myButtonName.Click += (press Tab twice)
and the handler will automatically be created for you.

Related

Having trouble in selecting ToolStrip button in Windows Form C#

I have this toolstrip on my windows form. When double clicking on ToolStrip button it gives me
my designer view:
my code view:
I'm wanting to have a button click event on every button and have a click event like on the image below.
their designer view:
their code view:
it seems like I can't click on the button directly, rather it selected the whole toolstrip instead.
Judging by the icon in the top left, this is netcore, or net5. Some things in winforms designer on these platforms are still very wonky and toolstrip related things seem to be one of them..
Change to winforms on .net framework if you can, or add your click event handlers in code if you can't:
write the name of your button in code, followed by .Click +=
Accept the suggestion to insert a method for you by pressing tab
It's because you doubled click the whole ToolStrip not the buttons on the ToolStrip

Click textbox to show popup, click outside to close popup

I am designing a WPF usercontrol, and there is a textbox and a popup under the textbox. I want to click the textbox, then the popup shows. If I click outside of the textbox, the popup closes.
Now the problem is how to unfocus the textbox if I click outside the usercontrol area? Is any better way to design this control? Thanks.
On click inside you should show your popup, and to close it ater click on non-user are try to use solutions from link Is there an event handler that is fired when mouse is clicked outside textbox in c# Windows Form application?

Want to do some stuff when ultracomboeditor got focused

I am using UltraComboEditior of Infragistics Conrtrols in C# winform application, I want to show a messageBox when UltroComboEditior got focues by MouseClick or KeyBoard Tab button, how can I do it? Any suggestions ? I tried BeforeDropDown but it is called only when we click on arrow button to show drop down list but I am using only drop down with auto complete option set to be true.
UltraComboEditor control has "Enter" event which fires when the control becomes the active control of the form, and this event will fire in both situations - when the control got focus by using your Tab key, and when you are using your mouse.
I hope that this will help you to achieve your goal.
Doesn't it inherit the OnGotFocus event which you can subscribe to?

How to tell when the user has clicked outside of the bounds your control?

I have a custom UserControl. I want to use it in a few different products, so I want something that can be implemented inside of the UserControl itself. I want to know when the user has clicked outside of the bounds of the UserControl so that I can hide it, similar to a ComboBox. How can I do that?
I tried handling the click event, but it only seems to fire if the click occured within the bounds of the control.
That's what the Capture property is designed to do. Set it to true and all mouse messages are routed to your control, even if it moves out of the window bounds. Check the e.Location property in the MouseDown event.
Hm, you may be able to accomplish what you want by listening to the GotFocus/LostFocus events. ComboBoxes give the drop downs focus when they open and close them when they lose focus.
do this
Select all controls on your form including form
In Property Window select MouseClick event
Now enter below Code in Common_MouseClick
Code:
if (!sender.Equals(yourControl))
{
yourControl.Visible=false;
}

AcceptsReturn equivalent for WebBrowser .NET control

I have a Windows .NET application and one of the forms has a WebBrowser control, an OK button and a Cancel button.
The WebBrowser control hosts a TextArea html element, so I can write inside.
If the OK button is the form's AcceptButton (form.AcceptButton = btnOk) then when I press Enter the event is captured by the form, and no new line is added in my TextArea.
TextBox has a property AcceptsReturn that does exactly what I would need, but there is no similar property for WebBrowser control.
Any ideas on how to retain the Enter event for the TextArea if the form which hosts the WebBrowser has an AcceptButton?
Thanks.
I think you'd have to turn off the AcceptButton on your form while the TextArea has the focus in order for this to work. Your form has no way of "knowing" that it's not supposed to respond to the Enter key while something in particular is going on inside the WebBrowser control.

Categories

Resources