How reject proposed value

  • Thread starter Thread starter Woody Splawn
  • Start date Start date
W

Woody Splawn

I have created an event handler for the ColumnChanging event of a grid. I
have code that looks like this

sProposed = EventData.ProposedValue.ToString

My question is this, if the proposed value is something unacceptable, what
is the code for informing the user that such is the case, rejecting the
value and keeping the user on the field till a right value is entered?
 
Hi Woody,

If you have another field in EventData which the event handler can set,
this can inform the method that raises the event whether the ProposedValue has
been accepted or rejected.

Much like Handled in the KeyPressEventArgs of Control.KeyPress, and Cancel
in the CancelEventArgs of Form.Closing.

Regards,
Fergus
 
Hi Fergus/Woody,

I'm assuming that your event data class derives from System.EventArgs...
Well instead, derive it from System.ComponentModel.CancelEventArgs.

Now, you can pass the 'Cancel' property back up the event chain and if
Cancel = True, don't do any event.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
 
Apparently my question was more elemental than you understood. The solution
is to throw an exception.

Thank you for your effort.
 
Hi Woody,

|| Apparently my question was more elemental than you
|| understood. The solution is to throw an exception.
||
|| Thank you for your effort.

Doh! How could I forget the elementals. I'll make a better effort to
understand next time.

;-)

Regards,
Fergus
 
Back
Top