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

public Object SelectedValue { get; set; }
/** @property */
public Object get_SelectedValue ()

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

public function get SelectedValue () : Object

public function set SelectedValue (value : Object)

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.

private 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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions