1 Replies - 4076 Views - Last Post: 17 January 2010 - 09:30 PM Rate Topic: -----

#1 gotagoJOE  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 12-June 09

add to combo box from textbox -diff forms

Post icon  Posted 17 January 2010 - 09:06 PM

namespace Passing_Data 
{ 
	public partial class Form1 : Form 
	{ 
		public Form1() 
		{ 
			InitializeComponent(); 
		} 
 
		private void button1_Click(object sender, EventArgs e) 
		{ 
			Form2 frm = new Form2(textBox1.Text); 
			frm.Show(); 
 
		} 
 
		private void Form1_Load(object sender, EventArgs e) 
		{ 
 
		} 
	} 
} 
FORM 2: 
namespace Passing_Data 
{ 
	public partial class Form2 : Form 
	{ 
		public Form2(String strTextBox) 
		{ 
			InitializeComponent(); 
			label1.Text = strTextBox; 
		} 
 
		private void Form2_Load(object sender, EventArgs e) 
		{ 
 
		} 
 
		private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) 
		{ 
 
		} 
	} 
} 


I have a form1 with textbox and command button- I enter data and click button to get form 2 - and data displays in label.
nowI want to be able to display data in combo box.
i have tried combobox1.items.add(strTextBox) - but tells me strTextBox not recognized-thank you (in form2 _load)

Is This A Good Question/Topic? 0
  • +

Replies To: add to combo box from textbox -diff forms

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: add to combo box from textbox -diff forms

Posted 17 January 2010 - 09:30 PM

Have a look at eclipsed4utoo's tutorial:

Passing Data Between Forms in C#

Here's another take on it: Passing Values between Forms

This post has been edited by n8wxs: 17 January 2010 - 09:45 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1