"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Monday, September 5, 2011

How to pass value from one form to another [Windows Application]

On form1
  •  
  • namespace WindowsFormsApplication1
  • {
  • public partial class Form1 : Form
  • {
  • Form2 ob;
  • public Form1()
  • {
  • InitializeComponent();
  • }
  •  
  • private void button1_Click(object sender, EventArgs e)
  • {
  • string s;
  • s = comboBox.SelectedIndex;
  • ob = new Form2(s);
  • ob.Show();
  • }
  • }
  • }
On form2
  • namespace WindowsFormsApplication1
  • {
  • public partial class Form2 : Form
  • {
  • string ss;
  • public Form2(string s)
  • {
  • InitializeComponent();
  • ss = s;
  • comboBox.SelectedIndex = ss;
  • }
  • }
  • }
Hope u got that Now !!!

Have a nice day... 'N happy Coding :)

No comments: