473,386 Members | 1,795 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,386 software developers and data experts.

How to get focused control name

Dear all,
is it possible to get a name of control on the form, which is currently in
focus.
Thanks,
Boni
Nov 23 '05 #1
8 21288
Dim c As Control = Me.ActiveControl

Greg

"Boni" <oilia@nospam> wrote in message
news:ef*************@TK2MSFTNGP09.phx.gbl...
Dear all,
is it possible to get a name of control on the form, which is currently in
focus.
Thanks,
Boni

Nov 23 '05 #2
> Dim c As Control = Me.ActiveControl

I think you may need to check Me.ActiveControl.Focused too. I confess to
some confusion (10 years worth) regarding these different form/control status
indicators.

Also, If you add controls to a form at runtime rather than in the designer,
then Me.ActiveControl.Name (what the original post asked for) will be
whatever you set it to.
Nov 23 '05 #3
A,,
Also, If you add controls to a form at runtime rather than in the
designer,
then Me.ActiveControl.Name (what the original post asked for) will be
whatever you set it to.

You confuse me, what do you mean with that?

Cor
Nov 23 '05 #4
I believe this means that when control is created programmatically Name
could be assigned to arbitrary value.

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
A,,
Also, If you add controls to a form at runtime rather than in the
designer,
then Me.ActiveControl.Name (what the original post asked for) will be
whatever you set it to.

You confuse me, what do you mean with that?

Cor

Nov 23 '05 #5
"Boni" <oilia@nospam> schrieb:
is it possible to get a name of control on the form, which is currently in
focus.


\\\
MsgBox(Me.ActiveControl.Name)
///

.... will work for the current form.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #6
However, Form.ActiveForm.ActiveControl is bogus. If Form.ActiveForm is
NOHTING, then you have NO way to get the active control on the top most
form. I have seen this issue before... for example if the top most
form as defined by Form.ActiveForm is NOT top of the ZORDER, aka., a
MsgBox or MessageBox is in front of the Form.ActiveForm is wrong AND if
you reference Form.ActiveForm INSIDE a Form at is TOP-MOST, it is OFTEN
set to NOTHING.

Nov 23 '05 #7
Dachshund,

You can be right, the same is when your computer is not running.

However, in my idea was Herfried giving a hint where to look for a solution
for this problem.

Just my thought,

Cor
Nov 23 '05 #8
To consistently get a valid form... I had to use GetActiveWindow() and
find the matching Window HANDLE from GetActiveWIndow() to a Form native
handle. Not pretty but worked for what I needed.

Dec 2 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: bala | last post by:
Iam using python....to invoke VBApplication...in the VBApplication contains lot controls...for Example 1.TextBox 2)CheckBox 3)Button 4)RadioButton 5)ComboBox 6)ListBox Outoff this six...
4
by: Weinand Daniel | last post by:
i'd like to monitor changes of the "Control.Name" porperty during designtime. if the user changes the name in designer my event musst fire. i have created a own button control. with an event...
3
by: B-Dog | last post by:
I'm capturing the checked radio button to XML file using the name of the radio button. I want to read my xml file to find which button was checked on close and the check the appropriate button...
3
by: Boni | last post by:
Dear all, if I have a Form and some controls on it, how can I get a pointer to the focused control. I what to remember focused control, do some operations and then restore focus
3
by: billq | last post by:
Hello, I have two custom control which will share a similar graphing function. The graphing function needs to communicate back to the calling control to gather information. I would like to send...
3
by: victor | last post by:
Hello guys, I'm stuck at the following situation, please advise. In my app there exists several control buttons (radio and push). One of the methods is the following: private void...
2
by: VMI | last post by:
In my Windows Form, is it possible to get the control name through object sender in an event handler? For example, in private void dataGridView_zip_KeyPress(object sender, KeyPressEventArgs e), how...
9
by: redivider | last post by:
I followed discussion "access form control propertys via control name as string " but am getting NullReferenceException when trying to access any controls via their name using "this.Controls". ...
2
by: ricardosms | last post by:
Hello: I have a custom control with a Combobox that at form1_Load gets filled with the names of the controls with visual interface. From this ComboBox the user selects a control name and that...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.