Hello, I have a simple question,
I have a vb.net form with several buttons.
If I store the name of a button in a variable..
Dim TheName as string
TheName = Me.btnMyLittleButton.Name.ToString
How can I disable this button using the variable value?
I can do this:
Me.btnMyLittleButton.Enabled = False
However, how can I get the name of the button (stored in TheName
variable ) and use it to disable it?
Is there a way to accomplish this without going through all the
controls in the form?
Don't want something like this:
Dim ctr As Control
For Each ctr In CurrentControl.Controls
If ctr.Name = TheName Then
ctr.Enabled = False
End If
Next
or writing the control names into a hashtable
What I want is something simple as the original example
Me.btnMyLittleButton.Enabled = False ---TheName.enabled = False
Does anyone has something better?
Thanks! 7 5687
On Apr 16, 3:48 pm, "John Smith" <I...@NETZERO.NETwrote:
Hello, I have a simple question,
I have a vb.net form with several buttons.
If I store the name of a button in a variable..
Dim TheName as string
TheName = Me.btnMyLittleButton.Name.ToString
How can I disable this button using the variable value?
I can do this:
Me.btnMyLittleButton.Enabled = False
However, how can I get the name of the button (stored in TheName
variable ) and use it to disable it?
Is there a way to accomplish this without going through all the
controls in the form?
Don't want something like this:
Dim ctr As Control
For Each ctr In CurrentControl.Controls
If ctr.Name = TheName Then
ctr.Enabled = False
End If
Next
or writing the control names into a hashtable
What I want is something simple as the original example
Me.btnMyLittleButton.Enabled = False ---TheName.enabled = False
Does anyone has something better?
Thanks!
Me.Controls[TheName].Enabled = False
You can access a control in the control collection by it's name in
2005.
--
Tom Shelton
On Apr 16, 9:35 pm, Tom Shelton <tom_shel...@comcast.netwrote:
On Apr 16, 3:48 pm, "John Smith" <I...@NETZERO.NETwrote:
Hello, I have a simple question,
I have a vb.net form with several buttons.
If I store the name of a button in a variable..
Dim TheName as string
TheName = Me.btnMyLittleButton.Name.ToString
How can I disable this button using the variable value?
I can do this:
Me.btnMyLittleButton.Enabled = False
However, how can I get the name of the button (stored in TheName
variable ) and use it to disable it?
Is there a way to accomplish this without going through all the
controls in the form?
Don't want something like this:
Dim ctr As Control
For Each ctr In CurrentControl.Controls
If ctr.Name = TheName Then
ctr.Enabled = False
End If
Next
or writing the control names into a hashtable
What I want is something simple as the original example
Me.btnMyLittleButton.Enabled = False ---TheName.enabled = False
Does anyone has something better?
Thanks!
Me.Controls[TheName].Enabled = False
You can access a control in the control collection by it's name in
2005.
--
Tom Shelton- Hide quoted text -
- Show quoted text -
Hi Tom, thanks for replying, but I am not using vb.net 2005. I have
VB.NET 2003.
If I use that code, I get the 'Enabled' is not a member of 'string'
error.
On Apr 16, 5:48 pm, "John Smith" <I...@NETZERO.NETwrote:
Hello, I have a simple question,
I have a vb.net form with several buttons.
If I store the name of a button in a variable..
Dim TheName as string
TheName = Me.btnMyLittleButton.Name.ToString
How can I disable this button using the variable value?
I can do this:
Me.btnMyLittleButton.Enabled = False
However, how can I get the name of the button (stored in TheName
variable ) and use it to disable it?
Is there a way to accomplish this without going through all the
controls in the form?
Don't want something like this:
Dim ctr As Control
For Each ctr In CurrentControl.Controls
If ctr.Name = TheName Then
ctr.Enabled = False
End If
Next
or writing the control names into a hashtable
What I want is something simple as the original example
Me.btnMyLittleButton.Enabled = False ---TheName.enabled = False
Does anyone has something better?
Thanks!
Do you have to store the button name into a variable? It would be a
lot easier to just store the button into the variable:
Dim theButton as Button = Me.btnMyLittleButton
theButton.Enabled = False
Thanks,
Seth Rowe
Hi Rowe, thanks for replying.
Well.. I cannot store the button into the variable. I'm supposed to
only know the button name.
I've tried to set the variable as a string, then as an object, but so
far I can't get it right.
I really hope this could be as easy as what Tom suggested:
Me.Controls[TheName].Enabled = False
The problem is that whenever I use the me. part, I get an error saying
that the variable is not a member of my form.
Is there a way to cast the variable as the button name using something
like DirectCast?
Thanks for all your help!
Well.. I cannot store the button into the variable. I'm supposed to
only know the button name.
Is this a school assignment?
I see no other time when you're only "supposed to know" a button name.
Thanks,
Seth Rowe
On Apr 17, 12:44 pm, John Smith <I...@NETZERO.NETwrote:
Hi Rowe, thanks for replying.
Well.. I cannot store the button into the variable. I'm supposed to
only know the button name.
I've tried to set the variable as a string, then as an object, but so
far I can't get it right.
I really hope this could be as easy as what Tom suggested:
Me.Controls[TheName].Enabled = False
The problem is that whenever I use the me. part, I get an error saying
that the variable is not a member of my form.
Is there a way to cast the variable as the button name using something
like DirectCast?
Thanks for all your help!
On Apr 17, 12:52 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
Well.. I cannot store the button into the variable. I'm supposed to
only know the button name.
Is this a school assignment?
I see no other time when you're only "supposed to know" a button name.
Thanks,
Seth Rowe
On Apr 17, 12:44 pm, John Smith <I...@NETZERO.NETwrote:
Hi Rowe, thanks for replying.
Well.. I cannot store the button into the variable. I'm supposed to
only know the button name.
I've tried to set the variable as a string, then as an object, but so
far I can't get it right.
I really hope this could be as easy as what Tom suggested:
Me.Controls[TheName].Enabled = False
The problem is that whenever I use the me. part, I get an error saying
that the variable is not a member of my form.
Is there a way to cast the variable as the button name using something
like DirectCast?
Thanks for all your help!- Hide quoted text -
- Show quoted text -
:-)
Yes, it is and it's driving me crazy!
On Apr 17, 2:10 pm, John Smith <I...@NETZERO.NETwrote:
On Apr 17, 12:52 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
Well.. I cannot store the button into the variable. I'm supposed to
only know the button name.
Is this a school assignment?
I see no other time when you're only "supposed to know" a button name.
Thanks,
Seth Rowe
On Apr 17, 12:44 pm, John Smith <I...@NETZERO.NETwrote:
Hi Rowe, thanks for replying.
Well.. I cannot store the button into the variable. I'm supposed to
only know the button name.
I've tried to set the variable as a string, then as an object, but so
far I can't get it right.
I really hope this could be as easy as what Tom suggested:
Me.Controls[TheName].Enabled = False
The problem is that whenever I use the me. part, I get an error saying
that the variable is not a member of my form.
Is there a way to cast the variable as the button name using something
like DirectCast?
Thanks for all your help!- Hide quoted text -
- Show quoted text -
:-)
Yes, it is and it's driving me crazy!
Why can't you loop through the control collection or use a hash table?
In the future you should ask your professor/teacher or a fellow
student for help - this newsgroup is not here to do your homework!
Thanks,
Seth Rowe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gary |
last post by:
I haver a table of students - Say 100 students that I need to be able to
update/delete and amend. I know I can do this one student at a time which is
simple but lets say I want to see all the...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen....
|
by: ratnakarp |
last post by:
Hi,
I have a search text box. The user enters the value in the text box and
click on enter button. In code behind on button click i'm writing the
code to get the values from the database and...
|
by: John Regan |
last post by:
Hello All
I am trying to find the owner of a file or folder on our network (Windows
2000 Server) using VB.Net and/or API. so I can search for Folders that don't
follow our company's specified...
|
by: Brett Wesoloski |
last post by:
I can not seem to figure this out, but really haven't work a lot with
javascrip and .NET.
I have a data grid and I want to put a button in it and when the button is
pressed it will call my...
|
by: KevinADC |
last post by:
Note: You may skip to the end of the article if all you want is the perl code.
Introduction
Uploading files from a local computer to a remote web server has many useful purposes, the most...
|
by: shivendravikramsingh |
last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
|
by: coflo |
last post by:
I am relatively new to XSL transforms so I apologize if my language or verbage is incorrect.
I am trying to invoke a JS function of a flash player which requires a URI. In order to do this I would...
|
by: sowmyati |
last post by:
HI All,
I am new to javascript. I have snippet wherein i am giving a brief note on what i am trying to do. In the below have a variable by name stuff. trying to reset the page. Part of the code...
|
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...
|
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...
|
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: 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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |