0
What code to type to select item in listbox making its price appear in textbox? If and else statement
Windows form application
2 Réponses
0
use valuemember and displaymember
http://www.tek-tips.com/viewthread.cfm?qid=778322
Fill your listbox with values
ArrayList Provinces = new ArrayList() ;
Provinces.Add(new Province("Alberta", "AB"));
Provinces.Add(new Province("Columbie Britanique", "CB")) ;
Provinces.Add(new Province("Quebec", "Qc"));
Provinces.Add(new Province("Ontario", "ON")) ;
Provinces.Add(new Province("Manitoba", "MN"));
listBox1.DataSource = Provinces ;
listBox1.DisplayMember = "LongName" ;
listBox1.ValueMember = "ShortName" ;
Get the selected value
if (listBox1.SelectedIndex != -1)
{
textBox1.Text = listBox1.SelectedValue.ToString();
}
0
thanks