This topic has not yet been rated - Rate this topic

ComboBox::IsReadOnly Property

Gets or sets a value that enables selection-only mode, in which the contents of the combo box are selectable but not editable.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
public:
property bool IsReadOnly {
	bool get ();
	void set (bool value);
}
<object IsReadOnly="bool" .../>

Property Value

Type: System::Boolean
true if the ComboBox is read-only; otherwise, false. The default is false.

Identifier field

IsReadOnlyProperty

Metadata properties set to true

Inherits

The IsEditable and IsReadOnly properties specify how the ComboBox behaves when the user does one of the following:

  • Enters a string to select an item in the ComboBox.

  • Enters a string that does not correspond to an item in the ComboBox.

  • Selects part of the string that is in the text box.

  • Copies or pastes a value into the text box.

The following table describes the actions the user can and cannot take, depending on the values of IsEditable and IsReadOnly.

IsReadOnly is true

IsReadOnly is false

IsEditable is true

  • Cannot select an item in the ComboBox by entering a string.

  • Cannot enter a string that does not correspond to an item in the ComboBox.

  • Can select part of the string in the ComboBox text box.

  • Can copy the string in the ComboBox text box, but cannot paste a string into the ComboBox text box.

  • Can select an item in the ComboBox by entering a string.

  • Can enter a string that does not correspond to an item in the ComboBox.

  • Can select part of the string in the ComboBox text box.

  • Can copy or paste the string in the ComboBox text box.

IsEditable is false

  • Can select an item in the ComboBox by entering a string.

  • Cannot enter a string that does not correspond to an item in the ComboBox.

  • Cannot select part of the string in the ComboBox.

  • Cannot copy or paste the string in the ComboBox.

  • Can select an item in the ComboBox by entering a string.

  • Cannot enter a string that does not correspond to an item in the ComboBox.

  • Cannot select part of the string in the ComboBox.

  • Cannot copy or paste the string in the ComboBox.

When IsEditable is equal to false, the ComboBox uses a ContentPresenter to display the currently selected item; when IsEditable is equal to true, a TextBox is used for this purpose instead. Note that a TextBox only displays plain text, and that a ComboBoxItem may include non-plain text content, such as images.

The following example shows a ComboBox with an editable TextBox. The IsReadOnly property is set to true, so the user cannot enter text into the TextBox.

<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">
</ComboBox>

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.