hi,
I am trying to get textbox value from a stackpanel. That stackpanel is a child of a popup. it is easy to add a stackpanel with its children into a popup content as child. But I cant succes reaching the value of textbox in that stackpanel.
My codes for creating popup
Dim pop As New Popup Dim text As New TextBlock Dim text1 As New TextBox Dim del As New Button del.Height = 30 del.Content = "delete" AddHandler del.Click, AddressOf del1_clicked Dim save As New Button save.Height = 30 save.Content = "save" AddHandler save.Click, AddressOf save1_clicked Dim ttt As New Button ttt.Height = 30 ttt.Content = "exit" AddHandler ttt.Click, AddressOf ttt1_clicked Dim sp As New StackPanel sp.Height = 150 sp.Width = 200 Dim row1 As DataRowView = DataGrid1.SelectedItems(0) text.Text = row1(0).ToString text1.Text = row1(1).ToString pop.Height = 150 pop.Width = 200 pop.HorizontalAlignment = Windows.HorizontalAlignment.Stretch pop.VerticalAlignment = Windows.VerticalAlignment.Center pop.Placement = System.Windows.Controls.Primitives.PlacementMode.Mouse pop.AllowsTransparency = True text.Background = Brushes.OrangeRed sp.Children.Add(text) sp.Children.Add(text1) sp.Children.Add(del) sp.Children.Add(save) sp.Children.Add(ttt) pop.Child = sp pop.Visibility = Windows.Visibility.Visible pop.IsOpen = True StackPanel2.Children.Add(pop)
with these codes I can call a popup menu via clicking a datagrid row. After opening popup I need the strings contained in textbox and textblock.
The image of popup
As you see, there are a textblock, a textbox and three buttons on the popup menu. I just need the values of prgramatically created textboxt and textblock for buttons' click events.
For save button's click event what have to I do ?
Private Sub save1_clicked(ByVal sender As Object, ByVal e As RoutedEventArgs) Dim but As Button = sender Dim sc As StackPanel = but.Parent Dim pop As Popup = sc.Parent
!!!!! dim txt as textbox = child of stackpanel , what I need to write here ????
!!!!! dim txt as textblock = child of stackpanel , what I need to write here ????
End Sub
Thanks in advance