Click here to Skip to main content
13,189,531 members (27,588 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am Stuck here in my project I have topic of airline reservation system in my form1
I am selecting source and destination in two different combobox and I want to show this selected source and destination which is selected by user in next form2 on load in DataGridView1.

(well i am beginner in vb give me hint with small code as example i ll make it in use as per to my project)
Thank you
Posted 15-Feb-13 0:43am
Updated 15-Feb-13 0:45am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

save value of both combo box in a public String variable
Code on form1 where there are 2 combo box
public strSource as string=""
public strDest as string=""
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
strSource =ComboBox1.Text
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
strDest =ComboBox2.Text
End Sub

Now on Form2 where there is DataGridView1 write below code on form2 load

i assume there are two coloums in DataGridView1
Happy Coding.....
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Exactly how you do this depends to an extent on how you display the two forms.

If you create the Form2 and display it from your Form1 (on a button click for example) then you can either write a Form2 constructor that accepts the information as parameters and displays it, or you can add public properties to Form2 which display the information. You can then set the information when you create the instance, and before you call ShowDialog.

If you already have Form2 open, created and displayed (via the Show method) from Form1, then create the properties as above and use Form2 instance you displayed to set the display information via those.

If the Form2 is created outside Form1 (by a parent form for example) then the best way is to create an event in Form1 which tells the parent to get the info and pass it to Form2 (again via Form2 properties)
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

If Len(Trim(combobx1.Text)) = Len(Trim(combobx2.Text)) Then
    MessageBox.Show("Please select another city", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Exit Sub
End If

this is solution which worked guys thnx for ur support. use this solution if u ant want to have same text value from two combobox to b used

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171016.2 | Last Updated 4 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100