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

How to identify Form.Control by sender

P: n/a
private void ValidationEvent(object sender, CancelEventArgs e)
{
if <...>{
this.errorMsg.SetError( sender, "Error");}
//error: /\
}

How to do indentify control by sender?

Form.ActiveControl points to next control.
May 19 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You just need to cast it to a control:
(Control)sender;

eg:
string name = ((Control)sender).Name;

to get its name.

- Mark

On Fri, 19 May 2006 13:39:05 +0800, Jazer <jo*************@gmail.com>
wrote:
private void ValidationEvent(object sender, CancelEventArgs e)
{
if <...>{
this.errorMsg.SetError( sender, "Error");}
//error: /\
}

How to do indentify control by sender?

Form.ActiveControl points to next control.


May 19 '06 #2

P: n/a
Thank you.
(sender as Control) could be too.
"Mark Harris" <it******@nospam.nospam> wrote in message
news:op***************@markxp.perth.itvision.com.a u...
You just need to cast it to a control:
(Control)sender;

eg:
string name = ((Control)sender).Name;

to get its name.

- Mark

On Fri, 19 May 2006 13:39:05 +0800, Jazer <jo*************@gmail.com>
wrote:
private void ValidationEvent(object sender, CancelEventArgs e)
{
if <...>{
this.errorMsg.SetError( sender, "Error");}
//error: /\
}

How to do indentify control by sender?

Form.ActiveControl points to next control.

May 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.