this.lstBox.SelectedValue returns an object of type as the ValueMember e.g.
If you say
this.lstBox.ValueMember = "ShortName"
that means that "ShortName" could be a column in a DataTable (datasource) with the name "ShortName" or something like you see in the example below using arraylist.
public class Province
{
private string myShortName ;
private string myLongName ;
public Province(string strLongName, string strShortName)
{
this.myShortName = strShortName;
this.myLongName = strLongName;
}
public string ShortName
{
get
{
return myShortName;
}
}
public string LongName
{
get
{
return myLongName ;
}
}
public override string ToString()
{
return this.ShortName + " - " + this.LongName;
}
}
Now in a form that contains the listBox1 control and a textBox1 control:
private void InitializeListBox()
{
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" ;
}
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (listBox1.SelectedIndex != -1)
{
textBox1.Text = listBox1.SelectedValue.ToString();
}
}
Here listBox1.SelectedValue will be a type of "string" because when the ValueMember was set to "ShortName" this one is a PROPERTY of type of "string" as you can see in the Province class definition :
public string ShortName
{
get
{
return myShortName;
}
}
This was mandatory to be defined in order to set it as a ValueMember.
-obislavu-