473,324 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to identify Form.Control by sender

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
2 1732
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
7
by: Amadelle | last post by:
Hi all and thanks in advance, I am stuck! I can't figure out how to identify which button was clicked on my ASP.NET page in the PostBack event? So what I am trying to do is to is to have an if...
5
by: Joey G | last post by:
How do I get the name or identify the control that caused the page postback. I need the information during page init. Reason why, because I need to tell usercontrol_1 that usercontrol_2 button was...
6
by: Woody Splawn | last post by:
I know that I can do the following to identify the parent name of an active control Dim sParentName As String = ActiveControl.Parent.Name But how do I identify the name of the active control?...
7
by: Grahmmer | last post by:
I have a few timers that are added to a form at runtime. I can handle the event fine, but I cannot identify which timer fired. Is there a way to do this? Timer Creation: -------------...
2
by: Justin | last post by:
I have a simple VB form with many controls. When user add/modify a record....if the user click the form close button...system should show a messagebox that "something is modified. Do you really...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
4
by: Me | last post by:
My form has a dynamically populated context menu, and each has the same event handler for the click event. The event need to write the text of the clicked menu item into a database, so I need to...
2
by: Bry | last post by:
I have a context menu which is shared between a TreeView and ListView control (both controls show the same information, similar to how Windows Explorer works, so it makes sense to use the same menu...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.