Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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
Edited 15-Feb-13 0:45am
v2
Rate this: bad
good
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)
    combobx2.Focus()
    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
  Permalink  
v3
Rate this: bad
good
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
DataGridView1.Rows.Add(form1.strSource,form1.strDest)   
 
i assume there are two coloums in DataGridView1
Happy Coding.....
  Permalink  
v2
Rate this: bad
good
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)
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 367
1 Abhinav S 226
2 thatraja 220
3 OriginalGriff 195
4 Peter Leow 160
0 Sergey Alexandrovich Kryukov 8,849
1 OriginalGriff 5,035
2 Peter Leow 3,949
3 Maciej Los 3,535
4 Abhinav S 3,148


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 4 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid