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













0















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!










share|improve this question
























  • 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















0















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!










share|improve this question
























  • 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













0












0








0








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!










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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

















  • 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
















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












1 Answer
1






active

oldest

votes


















0














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





share|improve this answer






















    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    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





    share|improve this answer



























      0














      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





      share|improve this answer

























        0












        0








        0







        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





        share|improve this answer













        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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 10 at 3:11









        RickRick

        1




        1





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme