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

Referencing Controls by Name in WinForms VB.NET

This is a WinForms question. In the VB6 world, you could
easily reference a control by name, e.g., if I want to
make the check box named chkFlag visible, I would do
this: frmMain.chkFlag.Visible = True.

In VB.NET, what is the proper way to reference controls
by name? frmMain.chkFlag does not work. chkFlag is in the
control collection of frmMain, so I could write a
generalized routine to recursively look thru the control
collections, but thats way too expensive.
Jul 21 '05 #1
1 3604
You should have to refer an instance of the frmMain in the memory. in vb.net
when we create frmmain form through IDE. we are just creating the class, not
any object.

so you can do like,

dim d as new frmmain
d.chkflag.visible = true
d.show()
Rajesh Patel
"Steve Floyd" <sf****@epripeac.com> wrote in message
news:11****************************@phx.gbl...
This is a WinForms question. In the VB6 world, you could
easily reference a control by name, e.g., if I want to
make the check box named chkFlag visible, I would do
this: frmMain.chkFlag.Visible = True.

In VB.NET, what is the proper way to reference controls
by name? frmMain.chkFlag does not work. chkFlag is in the
control collection of frmMain, so I could write a
generalized routine to recursively look thru the control
collections, but thats way too expensive.

Jul 21 '05 #2

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

Similar topics

0
by: Steve Floyd | last post by:
In VB6, I could reference controls on a form by name. For example, if I had a check box named chkFlag, I could do things like: frmMain.chkFlag.checked = True. What is the suggested way to...
1
by: Will | last post by:
Hi all. I'm learning VB.Net and am developing a WinForms app. I'm trying to make an app that I will use to scan in one or more than on image. I want to use a tabbed interface to hold each image....
3
by: 2obvious | last post by:
I have a DataGrid containing a TextBox control and a CustomValidator in each row. The CustomValidator fires a function that compares all TextBoxes for equality. The algorithm for comparison is...
2
by: Tamarack | last post by:
I have a simple function which loops through all the controls on a form searching for a specific one: Public Function FindControl(ByVal ctrls As Control.ControlCollection, ByVal ctrlName As...
1
by: Steve Floyd | last post by:
This is a WinForms question. In the VB6 world, you could easily reference a control by name, e.g., if I want to make the check box named chkFlag visible, I would do this: frmMain.chkFlag.Visible =...
2
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I...
4
by: OpticTygre | last post by:
I have a control I built, for which I would like to add a tool bar icon, but for some reason, it's not working correctly. There is no default namespace (I removed it from the properies page of...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
5
kcdoell
by: kcdoell | last post by:
Good Morning: I am using the following code to add new records to a table that is on my Sub Form. Below is the code that I placed in my Before Update event on my Sub Form: Private Sub...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.