-
May 19th, 2023, 07:49 AM
#1
Thread Starter
New Member
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
-
May 19th, 2023, 08:08 AM
#2
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.
-
May 19th, 2023, 08:31 AM
#3
Thread Starter
New Member
Re: Write a value to a textbox depending on variable
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)
-
May 19th, 2023, 09:05 AM
#4
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
-
May 19th, 2023, 10:58 AM
#5
Thread Starter
New Member
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
-
May 19th, 2023, 11:15 AM
#6
Re: Write a value to a textbox depending on variable
Sure thing mate. You have fun now
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|