By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,573 Members | 1,901 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,573 IT Pros & Developers. It's quick & easy.

How reject proposed value

P: n/a
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?

Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Nov 20 '05 #2

P: n/a
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
"Fergus Cooney" <fi******@tesco.net> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
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

Nov 20 '05 #3

P: n/a
Apparently my question was more elemental than you understood. The solution
is to throw an exception.

Thank you for your effort.
Nov 20 '05 #4

P: n/a
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
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.