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

How identify active control name

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

Str = activeControl.Name

does not seem to work.


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


P: n/a
it's should work. post your code snippet if you can't get it work.

Rajesh Patel

"Woody Splawn" <wo***@splawns.com> wrote in message
news:uK**************@tk2msftngp13.phx.gbl...
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?

Str = activeControl.Name

does not seem to work.

Nov 20 '05 #2

P: n/a
* "Woody Splawn" <wo***@splawns.com> scripsit:
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?

Str = activeControl.Name

does not seem to work.


Why doesn't it work? Error message?

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

P: n/a
I'm sorry, I gave you incorrect information. It does work when I use it,
for example, on a txtbox on a field on a winform but I am trying to make it
work for a field on a datagrid. That is, I am on a datagrid and I would
like to identify the field on the datagrid that I am on. I assume that is
considered by VS as the ActiveControl. My intent is to leave it and then
return to it. When I use code like the following under those circumstances
I get a result of nothing.

Str = activeControl.Name

Dim sParentName As String = ActiveControl.Parent.Name gives me the name of
the datagrid but I would like the field on the datagrid that I am currently
on.

Thank you in advance for your help.



Nov 20 '05 #4

P: n/a
Hi Woody,

Based on my understanding ,you want to know what field is the cell you are
selecting in.
I think you may try to get it from the datasouce. e.g. it is a dataset

Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles DataGrid1.CurrentCellChanged

MsgBox(DataSet11.Tables(0).Columns(DataGrid1.Curre ntCell.ColumnNumber).Colum
nName)
End Sub

Did I misunderstand you meaning?
If you have related question, please feel free to let me know.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Woody Splawn" <wo***@splawns.com>
References: <uK**************@tk2msftngp13.phx.gbl> <bm************@ID-208219.news.uni-berlin.de>Subject: Re: How identify active control name
Date: Mon, 13 Oct 2003 15:13:45 -0700
Lines: 22
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <u9**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:146430
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

I'm sorry, I gave you incorrect information. It does work when I use it,
for example, on a txtbox on a field on a winform but I am trying to make it
work for a field on a datagrid. That is, I am on a datagrid and I would
like to identify the field on the datagrid that I am on. I assume that is
considered by VS as the ActiveControl. My intent is to leave it and then
return to it. When I use code like the following under those circumstances
I get a result of nothing.

Str = activeControl.Name

Dim sParentName As String = ActiveControl.Parent.Name gives me the name of
the datagrid but I would like the field on the datagrid that I am currently
on.

Thank you in advance for your help.




Nov 20 '05 #5

P: n/a
Are you the Peter Huang of the Sacramento Calif area?
Nov 20 '05 #6

P: n/a
Hi Woody,

Did my suggestion works for you?
If you have any related question, please feel free to let me know.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
X-Tomcat-ID: 195548074
References: <uK**************@tk2msftngp13.phx.gbl> <bm************@ID-208219.news.uni-berlin.de>
<u9**************@tk2msftngp13.phx.gbl>MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: v-******@online.microsoft.com (Peter Huang [MSFT])
Organization: Microsoft
Date: Tue, 14 Oct 2003 07:57:25 GMT
Subject: Re: How identify active control name
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
Message-ID: <cN**************@cpmsftngxa06.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
Lines: 57
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:146476
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

Hi Woody,

Based on my understanding ,you want to know what field is the cell you are
selecting in.
I think you may try to get it from the datasouce. e.g. it is a dataset

Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles DataGrid1.CurrentCellChanged

MsgBox(DataSet11.Tables(0).Columns(DataGrid1.Curr entCell.ColumnNumber).Colu mnName)
End Sub

Did I misunderstand you meaning?
If you have related question, please feel free to let me know.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: "Woody Splawn" <wo***@splawns.com>
References: <uK**************@tk2msftngp13.phx.gbl>

<bm************@ID-208219.news.uni-berlin.de>
Subject: Re: How identify active control name
Date: Mon, 13 Oct 2003 15:13:45 -0700
Lines: 22
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <u9**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:146430
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

I'm sorry, I gave you incorrect information. It does work when I use it,
for example, on a txtbox on a field on a winform but I am trying to make itwork for a field on a datagrid. That is, I am on a datagrid and I would
like to identify the field on the datagrid that I am on. I assume that is
considered by VS as the ActiveControl. My intent is to leave it and then
return to it. When I use code like the following under those circumstancesI get a result of nothing.

Str = activeControl.Name

Dim sParentName As String = ActiveControl.Parent.Name gives me the name of
the datagrid but I would like the field on the datagrid that I am currentlyon.

Thank you in advance for your help.





Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.