Dave,
Yep, ok ... I see what you were getting at now. Good idea. =)
~~Bonnie
>This works:
>
>
>public event CancelEventHandler PreClick;
>...
>private void button1_Click(object sender, System.EventArgs e)
>{
> CancelEventArgs ce = new CancelEventArgs(true);
> if (PreClick != null)
> {
> PreClick(this, ce);
> }
> if (ce.Cancel == false)
> {
> MessageBox.Show("Parent Code");
> if (PostClick != null)
> {
> PostClick(this, new EventArgs());
> }
> }
>}
>
>
>Then on the form
>
>private void mybutton1_PreClick(object sender, CancelEventArgs e)
>{
> e.Cancel = this.checkBox1.Checked;
>}
>
>
>
>
>>Dave,
>>
>>
>The standard .net way of doing this is to use the CancelEventArgs class instead of the regular EventArgs class.>>
>>Yeah, all well and good for a Closing Event on a form, but I don't think that the Button Click event handles either a CancelEventHandler or CancelEventArgs. Unless I missed something when I tried it.
>>
>>~~Bonnie
>>
>>>
>>>It adds an additional Cancel property that your base class could process and cancel furthur processing of the event.
>>>
>>>See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodelcanceleventargsclasstopic.asp>>>
>>>>
>>>>This works great, but what I'm trying to achieve is to prevent this default parent code
>>>>
>>>>
>>>> '------------------default code goes here---------------------
>>>> MsgBox("parent click at class level")
>>>> '------------------default code goes here---------------------
>>>>
>>>>
>>>>from running if necessary, or maybe override it. For example something happens in my preclick method and I then decide to abort the action etc.