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

            Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

            Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

            How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page