ListControl.SelectedValue Property

Gets or sets the value of the member property specified by the ValueMember property.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

property Object^ SelectedValue {
	Object^ get ();
	void set (Object^ value);
/** @property */
public Object get_SelectedValue ()

/** @property */
public void set_SelectedValue (Object value)

public function get SelectedValue () : Object

public function set SelectedValue (value : Object)

Not applicable.

Property Value

An object containing the value of the member of the data source specified by the ValueMember property.

Exception typeCondition


The assigned value is a null reference (Nothing in Visual Basic) or the empty string ("").

If a property is not specified in ValueMember, SelectedValue returns the results of the ToString method of the object.

SelectedIndex, SelectedValue, and FormattingEnabled are related as follows:

  • If FormattingEnabled is false, SelectedIndex will not be set to -1 when SelectedValue is blank.

  • If FormattingEnabled is true, SelectedIndex will be set to -1 when SelectedValue is blank.

The following code example shows the SelectedValue returning the value of the property specified by the ValueMember property. This code is an excerpt from the example shown in the ListControl class overview. See ListControl for the whole code listing.

void ListBox1_SelectedValueChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
   if ( ListBox1->SelectedIndex != -1 )
         textBox1->Text = ListBox1->SelectedValue->ToString();

private void listBox1_SelectedValueChanged(Object sender, EventArgs e)
    if (listBox1.get_SelectedIndex() != -1) {
} //listBox1_SelectedValueChanged

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0