Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

popup window 1

Status
Not open for further replies.

stx

Programmer
Sep 24, 2002
62
BE
hi

Following problem. What is the best way to work with popup windows on my windows form application.I'll give an example to clarify my situation. I have a form where you have to give the customerid and it will get the according data from sql and show it to you. But mostly the user doesn't know the customerid by heart. So what i want to do is make another form (popup window) where they can search for customers and select one. When they have selected a customer i want to pass back the according customerid to my original form.

What is the best and right way to do this?
I'm using a popup-window because that way i can use it on other places in my project as well?

Any thoughts are welcome.
thnx.
 
Just create the form. Then "Pop-it-Up" when you want it

dim frm as new PopUpForm
frm.ShowDialog 'or frm.Show

If you need to pass the form some variables so that it knows what to display just declare the variables public on the Popup form and before calling the frm.ShowDialog shown above just set the variables on the frm to their values then call a Sub to fill the fields on the form. Like...

dim frm as new PopUpForm
frm.RecordId = intId
frm.FillFields
frm.ShowDialog

-Digiduck
 
Digiduck

thnx for the reply but what i want is just the opposite !
When a customer is selected on popup-form i want it to pass it back to the form that called the popup.

i clarify:

custform calls popupform.
On the popupform i select a customer.
Now popupform needs to be closed, and the selected id on popupform needs to be passed back to custform.

hope i made it a bit more clear.

thnx for the help

 
Oh okay. All you need is to reverse what I gave you to something like this...

'PARENT FORM
public RecordId as integer

dim frm as new PopUp
frm.sForm = me
frm.ShowDialog

'POPUP FORM
public sForm as ParentForm 'Where 'ParentForm' is the name of the parent form

sForm.RecordId = whatever
me.close


You could also do something like this which would be even easier. Make sure you set your OK / CANCEL buttons on the popup form with the corresponding DialogResult values, then...

'PARENT FORM
dim frm as new PopUpForm
if frm.showdialog = dialogresult.ok then
me.CustomerId = frm.CustomerId
end if

just make sure that you have the variable (CustomerId) public on the popup form.

-Digiduck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top