Text Property

ComboBox.Text Property


Gets or sets the text of the currently selected item.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public string Text { get; set; }

Property Value

Type: System.String

The string of the currently selected item. The default is an empty string ("").

When the IsEditable property is true, setting this property places initial text entered in the text box. When IsEditable is false, setting this value has no effect.

Identifier field


Metadata properties set to true

BindsTwoWayByDefault, Journal

This example shows how the Text property can be used to set text into the TextBox before the user makes a selection.

<ComboBox Name="cb" Margin="10,10,3,3" Width="200" Height="30" Grid.Column="0" Grid.Row="2"         
          ItemsSource="{StaticResource myCities}" Text="My Cities"
          IsEditable="true"  IsReadOnly="true" 
          IsDropDownOpen="True" StaysOpenOnEdit="True">

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft