By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,118 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,118 IT Pros & Developers. It's quick & easy.

windows form listbox.selectedvale

P: 2
hi ,

The below is my code. One the first form i would like to get the selected value the user chose, and pass this info to the second form for editing of thru the primary key ID.

But i can't seem to pass the selectedvale over. anybody can help see what's wrong?


Expand|Select|Wrap|Line Numbers
  1.  public void viewAllLocation_Load(object sender, EventArgs e)
  2.         {
  3.   listBox2.DataSource = type.getLocation();
  4.             listBox2.DisplayMember = "LocationName";
  5.             listBox2.ValueMember = "LocationID";
  6.  }
  7.  
  8.  public void button3_Click(object sender, EventArgs e)
  9.         {
  10.  
  11. updateLocation frm = new updateLocation(listBox2.SelectedItem.ToString());
  12.             frm.Show();
  13.  

Expand|Select|Wrap|Line Numbers
  1.  
  2. using System;
  3. using System.Windows.Forms;
  4.  
  5. namespace ListBoxMenuSample
  6. {
  7.     public partial class updateLocation : Form
  8.     {
  9.  
  10.         public updateLocation()
  11.         {
  12.             InitializeComponent();
  13.         }
  14.  
  15.  
  16.  
  17.         public string _textBox
  18.         {
  19.             set { textBox1.Text = value; }
  20.         }
  21.  
  22.         public updateLocation(string strTextBox)
  23. {
  24.   InitializeComponent();
  25.   textBox1.Text = strTextBox;
  26. }
  27.  
  28.  
  29.     }
  30. }
  31.  
  32.  
  33.  
Oct 21 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.