Write a value to a textbox depending on variable
Hello,
I have a WPF form and created a stackpanel with 5 textboxes. (TXT1, TXT2, TXT3 ....)
I want to fill these textboxes with a name out of a Global var named "NamePerson" and the textbox depending of the value of i.
Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
Stackpanel1.Children.Item(i).SetValue(NamePerson)
End Sub
Can anyone tell me how i can fix this?
Thanks in advance,
Erika
Re: Write a value to a textbox depending on variable
You have to cast Stackpanel1.Children.Item(i) to TextBox and then you can access it's Text property.
Re: Write a value to a textbox depending on variable
Quote:
Originally Posted by
Niya
You have to cast Stackpanel1.Children.Item(i) to TextBox and then you can access it's Text property.
And how do i do this? (i'm not experienced in WPF/.net)
Re: Write a value to a textbox depending on variable
Something like this:-
Code:
Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
DirectCast(Stackpanel1.Children(i), TextBox).Text = NamePerson
End Sub
Re: Write a value to a textbox depending on variable
Hello Niya,
Thank you very much, this is what i needed.
Now i can go further with my task.
Have a nice weekend.
Regards,
Erika
Re: Write a value to a textbox depending on variable
Sure thing mate. You have fun now :wave: