1

So I have a stack panel, and users click a button and it adds a text box in the stack panel. I got that down. The naming system is such that it names each textbox individually ("textboxname" + I). However, I have no clue how to get the text back from they textboxes to use elsewhere. Anyone got any idea for to get the text from a textbox that's a child of a stack panel?

LarsTech
  • 80,625
  • 14
  • 153
  • 225

1 Answers1

1

You can use:

Me.Controls.Find("yourTextBoxName", true)

Here passing true is necessary since it help to find the control in child controls as well. Since you have StackPanel over the root parent control and containing Textboxes.

For more info and a clear solution, you can check this link.

EDIT:

You should use this custom function.

Community
  • 1
  • 1
NeverHopeless
  • 11,077
  • 4
  • 35
  • 56
  • is this for C#? On VB.net I'm not seeing a me.controls option, its saying that controls isn't a member. – user3470664 Apr 01 '14 at 13:38
  • Its VB.Net, where do you write this ? in module or in form.vb file ? – NeverHopeless Apr 01 '14 at 13:49
  • Ah... I'm using WPF... no module, no form. Sorry man I forgot to say – user3470664 Apr 01 '14 at 17:04
  • Look at my edits as well as this link: http://social.msdn.microsoft.com/Forums/vstudio/en-US/6bd6c7fb-a209-4158-8ac6-27c0b9620c45/find-control-inside-a-wpf-user-control?forum=wpf – NeverHopeless Apr 01 '14 at 18:49
  • It doesn't seem to be finding the name of the dynamically created text boxes no matter how I try. However, It looks like if I just take the StackPanel.Children(i).tostring it gives me the type and then the value within the textbox. Its a very very dirty method but I cant see any other way of getting text out of these textboxes. – user3470664 Apr 01 '14 at 20:33