0 out of 2 rated this helpful - Rate this topic

ListBox.Text Property

Gets or searches for the text of the currently selected item in the ListBox.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
[BrowsableAttribute(false)]
[BindableAttribute(false)]
public override string Text { get; set; }

Property Value

Type: System.String
The text of the currently selected item in the control.

When the value of this property is set to a string value, the ListBox searches for the item within the ListBox that matches the specified text and selects the item. You can also use this property to determine which items are currently selected in the ListBox. If the SelectionMode property of the ListBox is set to SelectionMode.MultiExtended, this property returns the text of the first selected item. If the SelectionMode property of the ListBox is not set to SelectionMode.None, this property returns the text of the first selected item.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Listbox
I see there are 3 selection modes :  none, simple and multiextended.  I'm trying to put multiple items from the listobx but it only recognizes the first line or only one line that is selected.  For example, if I highlighted 40 items in the listbox it still only prints the first one selected.  I tried using in my code
Listbox1.Text.All but it gives me an error:

Argument not specified for the parameter 'predicate' of extension method 'Public function All(predicate as System.Func(of Char.Boolean)) As Boolean' defined in 'System.Linq.Enumerabl'.

Any thoughts?