wdw Posted February 25, 2003 Posted February 25, 2003 Hello, I have the following problem: I want to have a popup box that displays the results of a search in a datagrid. After displaying the results the user can select a row and then the form must be filled with that specified record. I know how to make a search method that displays data in a datagrid, but i don't know how to make it in a popup and i have no idea how to throw the information back to the form. can someone help me with this problem. I'm programming in vb.net (windowsforms application) thanks very much Willem Quote
*Experts* Nerseus Posted February 25, 2003 *Experts* Posted February 25, 2003 To get the popup window, you'll want the ShowDialog method of the form. To get values back, simply expose what you want as a public field on your popup form. For example, assume you have Form1 (the main window) and Form2, the popup. Also assume you want to expose the selected row as a DataRow on Form2, so that Form1 can display the data that was selected. Here's what Form1 might look like (maybe this is in a button click event or somesuch): Dim f2 As Form2 = New Form2() f2.ShowDialog() 'The following line will execute once Form2 has been closed If Not f2.SelectedRow Is Nothing Then 'They selected something, assign it to a local variable, dr 'dr would likely be stored at the form level, as a private DataRow variable dr = f2.SelectedRow End If The following chunk is in Form2: 'At the top of the form: Public SelectedRow As DataRow 'In the Double-Click event or a Select button's click event Me.SelectedRow = ... 'Select the Row from the grid and assign it here Me.Close() 'In the Close or Cancel button, if you have one: Me.Close() ' Nothing special, SelectedRow will default to Nothing -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
wdw Posted February 25, 2003 Author Posted February 25, 2003 thanks, This helps me on the way to get the solution i want. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.