I have the name of a control in a string variable and I want to change one
of the controls properties. Right now I recursively scan all the controls
on the form until I get one whose name matches the name in my string
variable, then I know I have the correct control and can proceed to change
the property.
However all that searching seems like overkill. Does anyone know of a way
to directly access the control if it's name is in a string variable?
Something like an indirect access...
Thanks for any advice... 9 1916
"JohnR" <Jo******@hotma il.com>'s wild thoughts were released
on Thu, 05 Jul 2007 05:02:56 GMT bearing the following
fruit:
>I have the name of a control in a string variable and I want to change one of the controls properties. Right now I recursively scan all the controls on the form until I get one whose name matches the name in my string variable, then I know I have the correct control and can proceed to change the property. However all that searching seems like overkill. Does anyone know of a way to directly access the control if it's name is in a string variable? Something like an indirect access... Thanks for any advice...
Me.Controls("Te xtEdit1").Text = "Hello"
--
Jan Hyde https://mvp.support.microsoft.com/profile/Jan.Hyde
JohnR wrote:
I have the name of a control in a string variable and I want to change one
of the controls properties. Right now I recursively scan all the controls
on the form until I get one whose name matches the name in my string
variable, then I know I have the correct control and can proceed to change
the property.
However all that searching seems like overkill. Does anyone know of a way
to directly access the control if it's name is in a string variable?
Something like an indirect access...
Thanks for any advice...
try Controls.Find [ http://msdn2.microsoft.com/en-us/library/ms404295.aspx]
Althought the MSDN sample is about keyed collectios, in the begining of
the page is shown how to focus on control specified by it's name.
Regards,
Petar Atansov http://a-wake.net
Jan,
Cylix is in my opinion doing it correct recursively, I assume he wants to
find the controls on a panel to.
Your me.controls shows in my idea only the controls on the top of the form.
Although I did not check it, the Find is also to find in a collection, not
to find a child in a collection.
However I am not 100% sure about the last.
Cor
"Jan Hyde (VB MVP)" <St***********@ REMOVE.ME.uboot .comschreef in bericht
news:a0******** *************** *********@4ax.c om...
"JohnR" <Jo******@hotma il.com>'s wild thoughts were released
on Thu, 05 Jul 2007 05:02:56 GMT bearing the following
fruit:
>>I have the name of a control in a string variable and I want to change one of the controls properties. Right now I recursively scan all the controls on the form until I get one whose name matches the name in my string variable, then I know I have the correct control and can proceed to change the property. However all that searching seems like overkill. Does anyone know of a way to directly access the control if it's name is in a string variable? Something like an indirect access... Thanks for any advice...
Me.Controls("Te xtEdit1").Text = "Hello"
--
Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde
On Jul 5, 6:52 am, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
wrote:
Jan,
Cylix is in my opinion doing it correct recursively, I assume he wants to
find the controls on a panel to.
Your me.controls shows in my idea only the controls on the top of the form.
Although I did not check it, the Find is also to find in a collection, not
to find a child in a collection.
However I am not 100% sure about the last.
Cor
"Jan Hyde (VB MVP)" <StellaDrin...@ REMOVE.ME.uboot .comschreef in berichtnews:a0* *************** *************** *@4ax.com...
"JohnR" <JohnR...@hotma il.com>'s wild thoughts were released
on Thu, 05 Jul 2007 05:02:56 GMT bearing the following
fruit:
>I have the name of a control in a string variable and I want to change one of the controls properties. Right now I recursively scan all the controls on the form until I get one whose name matches the name in my string variable, then I know I have the correct control and can proceed to change the property. However all that searching seems like overkill. Does anyone know of a way to directly access the control if it's name is in a string variable? Something like an indirect access... Thanks for any advice...
Me.Controls("Te xtEdit1").Text = "Hello"
--
Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde
Although I did not check it, the Find is also to find in a collection, not
to find a child in a collection.
Controls.Find has a searchAllChildr en bool parameter that you can use
to specify a recursive search.
Thanks,
Seth Rowe
Hi all,
Thanks for the great replies. Looks like Control.find will do what I want,
but that method was introduced in .NET 2.0 and we have not upgraded yet.
So, I'll continue doing it manually (at least it works), until we upgrade
later this year.
Thanks again...
"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ g4g2000hsf.goog legroups.com...
On Jul 5, 6:52 am, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
wrote:
>Jan,
Cylix is in my opinion doing it correct recursively, I assume he wants to find the controls on a panel to.
Your me.controls shows in my idea only the controls on the top of the form.
Although I did not check it, the Find is also to find in a collection, not to find a child in a collection.
However I am not 100% sure about the last.
Cor
"Jan Hyde (VB MVP)" <StellaDrin...@ REMOVE.ME.uboot .comschreef in berichtnews:a0 *************** *************** **@4ax.com...
"JohnR" <JohnR...@hotma il.com>'s wild thoughts were released
on Thu, 05 Jul 2007 05:02:56 GMT bearing the following
fruit:
>>I have the name of a control in a string variable and I want to change one of the controls properties. Right now I recursively scan all the controls on the form until I get one whose name matches the name in my string variable, then I know I have the correct control and can proceed to change the property. However all that searching seems like overkill. Does anyone know of a way to directly access the control if it's name is in a string variable? Something like an indirect access... Thanks for any advice...
Me.Controls("Te xtEdit1").Text = "Hello"
--
Jan Hyde
>https://mvp.support.microsoft.com/profile/Jan.Hyde
>Although I did not check it, the Find is also to find in a collection, not to find a child in a collection.
Controls.Find has a searchAllChildr en bool parameter that you can use
to specify a recursive search.
Thanks,
Seth Rowe
Seth
I had the plan to check it when I was home, but now you did it for me.
Thanks
Cor
"rowe_newsgroup s" <ro********@yah oo.comschreef in bericht
news:11******** **************@ g4g2000hsf.goog legroups.com...
On Jul 5, 6:52 am, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
wrote:
>Jan,
Cylix is in my opinion doing it correct recursively, I assume he wants to find the controls on a panel to.
Your me.controls shows in my idea only the controls on the top of the form.
Although I did not check it, the Find is also to find in a collection, not to find a child in a collection.
However I am not 100% sure about the last.
Cor
"Jan Hyde (VB MVP)" <StellaDrin...@ REMOVE.ME.uboot .comschreef in berichtnews:a0 *************** *************** **@4ax.com...
"JohnR" <JohnR...@hotma il.com>'s wild thoughts were released
on Thu, 05 Jul 2007 05:02:56 GMT bearing the following
fruit:
>>I have the name of a control in a string variable and I want to change one of the controls properties. Right now I recursively scan all the controls on the form until I get one whose name matches the name in my string variable, then I know I have the correct control and can proceed to change the property. However all that searching seems like overkill. Does anyone know of a way to directly access the control if it's name is in a string variable? Something like an indirect access... Thanks for any advice...
Me.Controls("Te xtEdit1").Text = "Hello"
--
Jan Hyde
>https://mvp.support.microsoft.com/profile/Jan.Hyde
>Although I did not check it, the Find is also to find in a collection, not to find a child in a collection.
Controls.Find has a searchAllChildr en bool parameter that you can use
to specify a recursive search.
Thanks,
Seth Rowe
JohnR,
If you need to do this for several controls, then you could scan all the
controls on the form once, adding the control to a hashtable and using the
control's name as the key.
Once all the controls are in the hashtable, you could access them by the
hashtable's key, the name of the control.
But this won't gain you any performance benefit if you just need to access
one control by name one time in your app.
Kerry Moorman
"JohnR" wrote:
Hi all,
Thanks for the great replies. Looks like Control.find will do what I want,
but that method was introduced in .NET 2.0 and we have not upgraded yet.
So, I'll continue doing it manually (at least it works), until we upgrade
later this year.
Thanks again...
"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ g4g2000hsf.goog legroups.com...
On Jul 5, 6:52 am, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
wrote:
Jan,
Cylix is in my opinion doing it correct recursively, I assume he wants to
find the controls on a panel to.
Your me.controls shows in my idea only the controls on the top of the
form.
Although I did not check it, the Find is also to find in a collection,
not
to find a child in a collection.
However I am not 100% sure about the last.
Cor
"Jan Hyde (VB MVP)" <StellaDrin...@ REMOVE.ME.uboot .comschreef in
berichtnews:a0* *************** *************** *@4ax.com...
"JohnR" <JohnR...@hotma il.com>'s wild thoughts were released
on Thu, 05 Jul 2007 05:02:56 GMT bearing the following
fruit:
I have the name of a control in a string variable and I want to change one of the controls properties. Right now I recursively scan all the controls on the form until I get one whose name matches the name in my string variable, then I know I have the correct control and can proceed to change the property. However all that searching seems like overkill. Does anyone know of a way to directly access the control if it's name is in a string variable? Something like an indirect access... Thanks for any advice...
Me.Controls("Te xtEdit1").Text = "Hello"
--
Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde
Although I did not check it, the Find is also to find in a collection,
not
to find a child in a collection.
Controls.Find has a searchAllChildr en bool parameter that you can use
to specify a recursive search.
Thanks,
Seth Rowe
Hi Kerry,
Ya know, that's a great idea. That's exactly what I'll do.
Thanks, John
"Kerry Moorman" <Ke**********@d iscussions.micr osoft.comwrote in message
news:2A******** *************** ***********@mic rosoft.com...
JohnR,
If you need to do this for several controls, then you could scan all the
controls on the form once, adding the control to a hashtable and using the
control's name as the key.
Once all the controls are in the hashtable, you could access them by the
hashtable's key, the name of the control.
But this won't gain you any performance benefit if you just need to access
one control by name one time in your app.
Kerry Moorman
"JohnR" wrote:
>Hi all,
Thanks for the great replies. Looks like Control.find will do what I want, but that method was introduced in .NET 2.0 and we have not upgraded yet. So, I'll continue doing it manually (at least it works), until we upgrade later this year. Thanks again...
"rowe_newsgrou ps" <ro********@yah oo.comwrote in message news:11******* *************** @g4g2000hsf.goo glegroups.com.. .
On Jul 5, 6:52 am, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
wrote: Jan,
Cylix is in my opinion doing it correct recursively, I assume he wants to find the controls on a panel to.
Your me.controls shows in my idea only the controls on the top of the form.
Although I did not check it, the Find is also to find in a collection, not to find a child in a collection.
However I am not 100% sure about the last.
Cor
"Jan Hyde (VB MVP)" <StellaDrin...@ REMOVE.ME.uboot .comschreef in berichtnews:a0 *************** *************** **@4ax.com...
"JohnR" <JohnR...@hotma il.com>'s wild thoughts were released
on Thu, 05 Jul 2007 05:02:56 GMT bearing the following
fruit:
I have the name of a control in a string variable and I want to change one of the controls properties. Right now I recursively scan all the controls on the form until I get one whose name matches the name in my string variable, then I know I have the correct control and can proceed to change the property. However all that searching seems like overkill. Does anyone know of a way to directly access the control if it's name is in a string variable? Something like an indirect access... Thanks for any advice...
Me.Controls("Te xtEdit1").Text = "Hello"
--
Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde
Although I did not check it, the Find is also to find in a collection, not to find a child in a collection.
Controls.Find has a searchAllChildr en bool parameter that you can use
to specify a recursive search.
Thanks,
Seth Rowe
On Jul 5, 3:52 pm, Kerry Moorman
<KerryMoor...@d iscussions.micr osoft.comwrote:
JohnR,
If you need to do this for several controls, then you could scan all the
controls on the form once, adding the control to a hashtable and using the
control's name as the key.
Once all the controls are in the hashtable, you could access them by the
hashtable's key, the name of the control.
But this won't gain you any performance benefit if you just need to access
one control by name one time in your app.
Kerry Moorman
"JohnR" wrote:
Hi all,
Thanks for the great replies. Looks like Control.find will do what I want,
but that method was introduced in .NET 2.0 and we have not upgraded yet.
So, I'll continue doing it manually (at least it works), until we upgrade
later this year.
Thanks again...
"rowe_newsgroup s" <rowe_em...@yah oo.comwrote in message
news:11******** **************@ g4g2000hsf.goog legroups.com...
On Jul 5, 6:52 am, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
wrote:
>Jan,
>Cylix is in my opinion doing it correct recursively, I assume he wants to
>find the controls on a panel to.
>Your me.controls shows in my idea only the controls on the top of the
>form.
>Although I did not check it, the Find is also to find in a collection,
>not
>to find a child in a collection.
>However I am not 100% sure about the last.
>Cor
>"Jan Hyde (VB MVP)" <StellaDrin...@ REMOVE.ME.uboot .comschreef in
>berichtnews:a0 *************** *************** **@4ax.com...
"JohnR" <JohnR...@hotma il.com>'s wild thoughts were released
on Thu, 05 Jul 2007 05:02:56 GMT bearing the following
fruit:
>>I have the name of a control in a string variable and I want to change
>>one
>>of the controls properties. Right now I recursively scan all the
>>controls
>>on the form until I get one whose name matches the name in my string
>>variable, then I know I have the correct control and can proceed to
>>change
>>the property.
>>However all that searching seems like overkill. Does anyone know of a
>>way
>>to directly access the control if it's name is in a string variable?
>>Something like an indirect access...
>>Thanks for any advice...
Me.Controls("Te xtEdit1").Text = "Hello"
--
Jan Hyde
>https://mvp.support.microsoft.com/profile/Jan.Hyde
>Although I did not check it, the Find is also to find in a collection,
>not
>to find a child in a collection.
Controls.Find has a searchAllChildr en bool parameter that you can use
to specify a recursive search.
Thanks,
Seth Rowe
You might also want to subscribe to the form's controladded event and
add any dynamically created controls that were created after your scan
to your hashtable.
Thanks,
Seth Rowe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joe |
last post by:
Hi,
I am trying to alter the refresh rate of an online webpage in a webbrowser
control using MFC. However the Timer ID is stored in a local variable and I
don't know how to access it. Is there a technique in Javascript that I might
be able to use/adapt?
I have a timer set within a prototype thus:
;HControl.prototype.setFLTimeout = function() {
|
by: Chris Styles |
last post by:
Dear All,
I've been using some code to verify form data quite happily, but i've
recently changed the way my form is structured, and I can't get it to work
now.
Originally :
The form is called "form1", and I have selects called "PORTA", "PORTB" ...
etc...
|
by: Matt Smolic |
last post by:
02.06.04
I need some help displaying a public variable on a form. The variable is
declared and initilazied in a module at startup (and declared Public). I
have verified this with a msgBox(dbprogram) call. When I try to display it
in the form in a text box I get a #Name? error instead. I was told I have to
write a function to display it. I wrote a public function in the startup
module to return the value of a given string variable. Below...
|
by: Vivek Sharma |
last post by:
Hi,
I have created a dropdownlist as a web user control. I am using its
multiple instances on the webpage. How do I access the selectedValue of
each instance? All the instances have different IDs.
Thanks
Vivek
|
by: Dan Nash |
last post by:
Hi all,
I've got a page with a user control on, added via VS. I'm trying to get to a
property of the user control (or more precisely, a public var).
Here's the code at the top of my aspx page...
<%@ Register TagPrefix="dI2" TagName="dartsUC_rolodexsearch"
Src="dartsUC_rolodexsearch.ascx" %>
| |
by: David Hearn |
last post by:
I have a property in a user control that I am setting:
Private strPageName as String
Public Property PageName() as String
Get
Return strPageName
End Get
Set(byVal Value as String)
strPageName = Value
End Set
|
by: Vincent |
last post by:
I have been trying to find some API routines that will allow me to
determine the name of the computer that is accessing a file on a
server. I have found the NetFileEnum call (returns the names of the
files in use and the names of the users accessing them). I have also
found the NetConnectionEnum call (returns the name of the computer that
is accessing a share). I do not see any way of correlating the data
that these two api calls...
|
by: John Kotuby |
last post by:
Hi all,
I am using a Repeater in conjunction with a SQLDatasource and SQL Server.
One of the controls in the repeater is a HyperlLink as follows:
<asp:HyperLink NavigateUrl='Search.aspx?page=base&searchid=<%
Eval("sequence")%>' .....
As you can see I am trying to pass a QueryString evaluated at runtime. All
the other Evals of DataFields in the Repeater are working just fine. However
this NavigateUrl is resolving as...
|
by: ansh20 |
last post by:
I am adding run time generate controls in array. Now I want to retrieve those controls in other subroutine in same form. But when I am tring to retrieve control it says "Object variable or with variable not set". It seems like at the time of adding controls, there is mistake.
AnyOne can help me? I am stuck since yesterday. Here is code for what I am trying.
Private myControlArray() As Control
Private userPromtedValue(50) As String
Public...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |