views:

209

answers:

1

In my cf.net project, I have a main "parent" form that will sometimes display a child-form like so:

Subform A = new SubForm();
A.ShowDialog();
//Get a property from the SubForm and use it.

In my subform contains some linkLabels. The linkLabel's click event does something and sets the dialogresult like this:

this.TextProperty = SomeNeatValue;
this.DialogResult = DialogResult.OK;
//This subform disappears and code resumes on the main form.

My main form also has a MouseUp() handler that does something whenever a control isn't clicked. But the main form's MouseUp() handler is being called after the linkLabel in the SubForm is clicked and the SubForm is dismissed!

I want the SubForm's linkLabel to totally consume the click and for the main form not to get it, but I can't find any way to prevent this. Can anyone help me?

+1  A: 

Don't use the click event on the link label. See if you can find a way to use MouseUp instead of click (which is possibly working off mouse down).

I had the same issue with KeyUp/Down a while back and the only way I could solve it was to ensure I consistently used the same event across the entire app.

Quibblesome
Unfortunately, a linklabel doesn't have MouseUp/MouseDown events. Just EnabledChanged, Click, GotFocus,LostFocus,ParentChanged,TextChanged.
Jake Stevenson
Inherit from LinkLabel and override MouseUp/MouseDown and don't handle the click event.
Quibblesome

related questions