Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to get the selected item from listbox(retrived items from database) to another form in vb.net?
Posted

1 solution

Exactly how you do it depends on the relationship between the two forms: Is one form the child of another? Or are they both children of a third form?
There are a set of tips here which describe the process:

Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]

The code is in C#, but it should be pretty easy to translate to VB.
 
Share this answer
 
Comments
sandhyagor 5-May-13 5:23am    
thnak you..
but two forms are different than each other.. they dont have any relationship..
then what to do???
OriginalGriff 5-May-13 5:46am    
They do - because unless they are in different applications then they will be opened by something.
If Form1 opens Form2 to do something, then Form1 is the Parent of Form2 and Form2 is the Child.
If both Form1 and Form2 are opened by Form3, then Form3 is the parent, and the others are both children. The parent has to know that the children exist and what type of form they are, but the children should not know what the parent is.

Without looking at you code, I can't tell you which of your forms is which!
sandhyagor 5-May-13 6:14am    
actually there is one form namely test_selection from where through listbox user can select test(records in the listbox is retrived from database)and then one another form is dispalyed and then after main exam form ll be display. i want to display the selected item from listbox(of test_selection form) to the exam form.
OriginalGriff 5-May-13 6:26am    
So are the "one another form" and "main exam form" displayed from test_selection? As in at some point you will have code like:
MyOtherForm mof = new MyOtherForm();
mof.ShowDialog();
or
MyOtherForm mof = new MyOtherForm();
mof.Show();
And similar for your MainExamForm.
Where is that code? Which form is it in?
sandhyagor 5-May-13 8:15am    
yea its true..
another form is displayed after test_selection and mainExam form is diaplayed after anotherform. and my question is that how to get selected item of listbox(of test_selection form) to the mainexam form???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900