hey ppl, i am having a problem with a control, my control is a background with a label on it, then when i use my control on my form i use the on click event, and it only happens when u click the control itself and not the label, so i was wondering how can i do that no matter where u click inside the control , fires the click event.
pls post me some code :(
mig16
thx

C# Windows Control
ozan celikada
[code lang="C#"]private void MigBtn_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseDown = true;
this.Invalidate();
}
}
private void MigBtn_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseDown = false;
this.Invalidate();
}
}[/code]
the label have that events and also the user control, but this is not the problem, the problem is when i add the control to a form and i assign the mouseDown event for the control, it just fires when u click on the user control area, when u click on the label area it draws an effect like u clicked but it doesnt fire the event in my form.
if u want an example here is the program and u will se that it works like a button allways but when u click on the label area, im looking for the way to merge label and user control :(
HERES THE EXAMPLE:
http://usuarios.lycos.es/mig16/ConfigBtn.zip
mig16
Frank213
this.Click += new EventHandler(MyUserControl_Click);
this.label1.Click += new EventHandler(MyUserControl_Click);
Just make the label handle the same event that your UserControl is handling. Now no matter where you click on the UserControl it will work now.
Cheers,
Aaron
http://aaronfeng.blogspot.com/
78Spit1500Fed
thx
mig16
nullsmind
Have you really connected the clickevent handler to the label that you are attaching to the form
Is what the event handler does really the same if the label is the sender
I.e., show your code! :)
projecttoday
Looks like a focus problem. Depending on the rest of yoru code the effect of the call to Invalidate may just be waiting while the label has focus.