How do I reference a dynamically named control on a UserControl from the Parent Form?Silverlight 4 Usercontrol Property fails to receive PropertyChanged From Parent ControlHow to prevent a consumer of a UserControl from seeing the control's child controls?vb.net winform from a usercontrol call a function on the parent formPass Databinding From Child Control Through Parent UserControlCalling specific UserControl dynamically createdHow to enable my usercontrol to define controls into its parent form at design-time?Passing Values from Multiple UserControlsAdding a User Control dynamically to a FlowLayoutPanelHow can a UserControl be notified when its parental Form obtains or loses its focus?Dynamically Add UserControl to Form
Multiplicative persistence
Melting point of aspirin, contradicting sources
How to explain what's wrong with this application of the chain rule?
Freedom of speech and where it applies
It grows, but water kills it
Is it possible to have a strip of cold climate in the middle of a planet?
What is this called? Old film camera viewer?
Are paving bricks differently sized for sand bedding vs mortar bedding?
Why electric field inside a cavity of a non-conducting sphere not zero?
Is it improper etiquette to ask your opponent what his/her rating is before the game?
How much character growth crosses the line into breaking the character
What was the exact wording from Ivanhoe of this advice on how to free yourself from slavery?
Delivering sarcasm
The IT department bottlenecks progress. How should I handle this?
Lowest total scrabble score
What if a revenant (monster) gains fire resistance?
Pre-mixing cryogenic fuels and using only one fuel tank
How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?
Can I sign legal documents with a smiley face?
When were female captains banned from Starfleet?
Where does the bonus feat in the cleric starting package come from?
Problem with TransformedDistribution
What is the evidence for the "tyranny of the majority problem" in a direct democracy context?
Is there any references on the tensor product of presentable (1-)categories?
How do I reference a dynamically named control on a UserControl from the Parent Form?
Silverlight 4 Usercontrol Property fails to receive PropertyChanged From Parent ControlHow to prevent a consumer of a UserControl from seeing the control's child controls?vb.net winform from a usercontrol call a function on the parent formPass Databinding From Child Control Through Parent UserControlCalling specific UserControl dynamically createdHow to enable my usercontrol to define controls into its parent form at design-time?Passing Values from Multiple UserControlsAdding a User Control dynamically to a FlowLayoutPanelHow can a UserControl be notified when its parental Form obtains or loses its focus?Dynamically Add UserControl to Form
How do I reference a dynamically named control on a UserControl from the Parent Form? (In Winforms).
I have a single parent form but it may load any 1 of around 20 or so UserControls. We will call them ucA, ucB, etc
.
Each UserControl has a different number of textboxes, but are named tbA01, tbA02, etc on ucA and tbB01, tbB02, etc on ucB
.
How would I reference the value of the textboxes?
I cannot seem to reference the name of the UserControl directly. I know the name of the UserControl as a string, but canot seem to cast it as a control. Likewise with the textboxes on the UserControl. I am sure I can use Control.Find() for the name of the textbox from a simple string. But this doesn't appear to be working, which I assume it will only be looking for controls on ParentForm and not the collection of controls on the UserControl. I assume there would be a method using TryCast or DirectCast and using the Control.Find() in the arguments. But I have not found a solution.
Any help would be appreciated!
vb.net textbox user-controls
add a comment |
How do I reference a dynamically named control on a UserControl from the Parent Form? (In Winforms).
I have a single parent form but it may load any 1 of around 20 or so UserControls. We will call them ucA, ucB, etc
.
Each UserControl has a different number of textboxes, but are named tbA01, tbA02, etc on ucA and tbB01, tbB02, etc on ucB
.
How would I reference the value of the textboxes?
I cannot seem to reference the name of the UserControl directly. I know the name of the UserControl as a string, but canot seem to cast it as a control. Likewise with the textboxes on the UserControl. I am sure I can use Control.Find() for the name of the textbox from a simple string. But this doesn't appear to be working, which I assume it will only be looking for controls on ParentForm and not the collection of controls on the UserControl. I assume there would be a method using TryCast or DirectCast and using the Control.Find() in the arguments. But I have not found a solution.
Any help would be appreciated!
vb.net textbox user-controls
Have the UserControls expose public methods or properties that allow anything else that is aware of the UserControl existence, to get or set an internal value (the Text property of a TextBox, for example). The same thing you do with a ComboBox or a ListBox: you don't directly set the Text of the Edit Control of the Items of a ListControl. You use public properties/methods.
– Jimi
Mar 8 at 4:48
I cannot seem to reference the name of the UserControl directly. This is unlikely. You have an instance of the UserControl inside the Form. Did you add the UserControl at run-time? Insert the UCs you build in aList(Of UserControl)
and use that to reference the UCs or use Controls.Find() to retrieve the instance(s).
– Jimi
Mar 8 at 5:13
add a comment |
How do I reference a dynamically named control on a UserControl from the Parent Form? (In Winforms).
I have a single parent form but it may load any 1 of around 20 or so UserControls. We will call them ucA, ucB, etc
.
Each UserControl has a different number of textboxes, but are named tbA01, tbA02, etc on ucA and tbB01, tbB02, etc on ucB
.
How would I reference the value of the textboxes?
I cannot seem to reference the name of the UserControl directly. I know the name of the UserControl as a string, but canot seem to cast it as a control. Likewise with the textboxes on the UserControl. I am sure I can use Control.Find() for the name of the textbox from a simple string. But this doesn't appear to be working, which I assume it will only be looking for controls on ParentForm and not the collection of controls on the UserControl. I assume there would be a method using TryCast or DirectCast and using the Control.Find() in the arguments. But I have not found a solution.
Any help would be appreciated!
vb.net textbox user-controls
How do I reference a dynamically named control on a UserControl from the Parent Form? (In Winforms).
I have a single parent form but it may load any 1 of around 20 or so UserControls. We will call them ucA, ucB, etc
.
Each UserControl has a different number of textboxes, but are named tbA01, tbA02, etc on ucA and tbB01, tbB02, etc on ucB
.
How would I reference the value of the textboxes?
I cannot seem to reference the name of the UserControl directly. I know the name of the UserControl as a string, but canot seem to cast it as a control. Likewise with the textboxes on the UserControl. I am sure I can use Control.Find() for the name of the textbox from a simple string. But this doesn't appear to be working, which I assume it will only be looking for controls on ParentForm and not the collection of controls on the UserControl. I assume there would be a method using TryCast or DirectCast and using the Control.Find() in the arguments. But I have not found a solution.
Any help would be appreciated!
vb.net textbox user-controls
vb.net textbox user-controls
edited Mar 8 at 7:20
tomerpacific
1,096824
1,096824
asked Mar 8 at 4:37
RickRick
1
1
Have the UserControls expose public methods or properties that allow anything else that is aware of the UserControl existence, to get or set an internal value (the Text property of a TextBox, for example). The same thing you do with a ComboBox or a ListBox: you don't directly set the Text of the Edit Control of the Items of a ListControl. You use public properties/methods.
– Jimi
Mar 8 at 4:48
I cannot seem to reference the name of the UserControl directly. This is unlikely. You have an instance of the UserControl inside the Form. Did you add the UserControl at run-time? Insert the UCs you build in aList(Of UserControl)
and use that to reference the UCs or use Controls.Find() to retrieve the instance(s).
– Jimi
Mar 8 at 5:13
add a comment |
Have the UserControls expose public methods or properties that allow anything else that is aware of the UserControl existence, to get or set an internal value (the Text property of a TextBox, for example). The same thing you do with a ComboBox or a ListBox: you don't directly set the Text of the Edit Control of the Items of a ListControl. You use public properties/methods.
– Jimi
Mar 8 at 4:48
I cannot seem to reference the name of the UserControl directly. This is unlikely. You have an instance of the UserControl inside the Form. Did you add the UserControl at run-time? Insert the UCs you build in aList(Of UserControl)
and use that to reference the UCs or use Controls.Find() to retrieve the instance(s).
– Jimi
Mar 8 at 5:13
Have the UserControls expose public methods or properties that allow anything else that is aware of the UserControl existence, to get or set an internal value (the Text property of a TextBox, for example). The same thing you do with a ComboBox or a ListBox: you don't directly set the Text of the Edit Control of the Items of a ListControl. You use public properties/methods.
– Jimi
Mar 8 at 4:48
Have the UserControls expose public methods or properties that allow anything else that is aware of the UserControl existence, to get or set an internal value (the Text property of a TextBox, for example). The same thing you do with a ComboBox or a ListBox: you don't directly set the Text of the Edit Control of the Items of a ListControl. You use public properties/methods.
– Jimi
Mar 8 at 4:48
I cannot seem to reference the name of the UserControl directly. This is unlikely. You have an instance of the UserControl inside the Form. Did you add the UserControl at run-time? Insert the UCs you build in a
List(Of UserControl)
and use that to reference the UCs or use Controls.Find() to retrieve the instance(s).– Jimi
Mar 8 at 5:13
I cannot seem to reference the name of the UserControl directly. This is unlikely. You have an instance of the UserControl inside the Form. Did you add the UserControl at run-time? Insert the UCs you build in a
List(Of UserControl)
and use that to reference the UCs or use Controls.Find() to retrieve the instance(s).– Jimi
Mar 8 at 5:13
add a comment |
1 Answer
1
active
oldest
votes
Thank you Jimi! Your answer did help me look at a different method in coming up with a solution. I have it working now. Here is what I used:
Dim matches() As Control
matches = Me.Controls.Find(TblName, True)
If matches.Length > 0 AndAlso TypeOf matches(0) Is TextBox Then
Dim tb As TextBox = DirectCast(matches(0), TextBox)
...
Endif
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056816%2fhow-do-i-reference-a-dynamically-named-control-on-a-usercontrol-from-the-parent%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thank you Jimi! Your answer did help me look at a different method in coming up with a solution. I have it working now. Here is what I used:
Dim matches() As Control
matches = Me.Controls.Find(TblName, True)
If matches.Length > 0 AndAlso TypeOf matches(0) Is TextBox Then
Dim tb As TextBox = DirectCast(matches(0), TextBox)
...
Endif
add a comment |
Thank you Jimi! Your answer did help me look at a different method in coming up with a solution. I have it working now. Here is what I used:
Dim matches() As Control
matches = Me.Controls.Find(TblName, True)
If matches.Length > 0 AndAlso TypeOf matches(0) Is TextBox Then
Dim tb As TextBox = DirectCast(matches(0), TextBox)
...
Endif
add a comment |
Thank you Jimi! Your answer did help me look at a different method in coming up with a solution. I have it working now. Here is what I used:
Dim matches() As Control
matches = Me.Controls.Find(TblName, True)
If matches.Length > 0 AndAlso TypeOf matches(0) Is TextBox Then
Dim tb As TextBox = DirectCast(matches(0), TextBox)
...
Endif
Thank you Jimi! Your answer did help me look at a different method in coming up with a solution. I have it working now. Here is what I used:
Dim matches() As Control
matches = Me.Controls.Find(TblName, True)
If matches.Length > 0 AndAlso TypeOf matches(0) Is TextBox Then
Dim tb As TextBox = DirectCast(matches(0), TextBox)
...
Endif
answered Mar 10 at 3:11
RickRick
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056816%2fhow-do-i-reference-a-dynamically-named-control-on-a-usercontrol-from-the-parent%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have the UserControls expose public methods or properties that allow anything else that is aware of the UserControl existence, to get or set an internal value (the Text property of a TextBox, for example). The same thing you do with a ComboBox or a ListBox: you don't directly set the Text of the Edit Control of the Items of a ListControl. You use public properties/methods.
– Jimi
Mar 8 at 4:48
I cannot seem to reference the name of the UserControl directly. This is unlikely. You have an instance of the UserControl inside the Form. Did you add the UserControl at run-time? Insert the UCs you build in a
List(Of UserControl)
and use that to reference the UCs or use Controls.Find() to retrieve the instance(s).– Jimi
Mar 8 at 5:13