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 1:43am
Edited 15-Feb-13 1:45am
v2
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  
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

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

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 BillWoodruff 85
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 4 May 2013
Copyright © CodeProject, 1999-2014
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