Move Data From popup form to Textbox

  • Thread starter Thread starter Paul Ilacqua
  • Start date Start date
P

Paul Ilacqua

I have a main VB 2005 form, with a button to launch a popup form
with a ListView containing available choices. My aim is to send the
Listview's value back to the main form and close the popup.
On the double click event of the Listview is where I'm trying to pass the
value back to the main form. That is where I'm stuck. I cannot code the call
to move the data from the popup form to the Main form.
Please lead me in the right direction.

Thank you
Paul
 
Paul said:
I have a main VB 2005 form, with a button to launch a popup form
with a ListView containing available choices. My aim is to send the
Listview's value back to the main form and close the popup.
On the double click event of the Listview is where I'm trying to pass the
value back to the main form. That is where I'm stuck. I cannot code the call
to move the data from the popup form to the Main form.
Please lead me in the right direction.

Is the popup form shown modally (showdialog) or modeless (show)? I guess
it's the former. After ShowDialog returns, you can access the controls
and get the selection from the listview.

'pseudo-like code

using f=new popupform
if f.showdialog = ok
dest = f.listview.selecteditem
end if
end using

Make the popup form return ok by setting it's dialogresult property
in the listview's double click event. This also closes the Form;
no need to call Close explicitly.
 
Armin,
Thank you so much.. I never would have arrived at that solution.
My next goal is ... Since the Popup goes against a SQL Server to populate
the list, I'd like to open the Form once, then hide it for the remainder of
the session, except pop it back up to select a part again. I cannot keep
calling the new if the form is hidden correct?
Thanks again
Paul
 
Paul said:
Armin,
Thank you so much.. I never would have arrived at that solution.
My next goal is ... Since the Popup goes against a SQL Server to populate
the list, I'd like to open the Form once, then hide it for the remainder of
the session, except pop it back up to select a part again. I cannot keep
calling the new if the form is hidden correct?
Thanks again
Paul

With a modal Form, you can reuse the instance after closing it. You just have to

- declare the variable at a place that doesn't run out of scope between
the two calls to ShowDialog, usually as a field of the calling class.

- not dispose the Form after Showdialog returns. That means, you must not use
the "Using" statment. (you're using VB?) In opposite to modeless Forms,
a modal Form is not automatically disposed whenever it's being closed.
 
Armin,
Yes I am using VB.. Thanks again for the "explanation" of your answer.
This method will allow me to reuse that same popup throughout my
application.
Happy New Year
Paul
 
Back
Top