Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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. This is a dependency property.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public bool IsReadOnly { get; set; }
/** @property */
public boolean get_IsReadOnly ()

/** @property */
public void set_IsReadOnly (boolean value)

public function get IsReadOnly () : boolean

public function set IsReadOnly (value : boolean)

<object IsReadOnly="bool" .../>

Property Value

A Boolean value that indicates whether a ComboBox is read-only; true if the ComboBox is read-only false otherwise. The default value is false.

Identifier Field

IsReadOnlyProperty

Metadata Flags

None

The IsEditable property is used in conjunction with the IsReadOnly property to control the level to which the display Text of the ComboBox is editable or selectable.  Here, "selectable" refers to the ability to use the mouse or keyboard to highlight a portion of content for operations such as Copy or Cut, as opposed to selecting a particular item in the ComboBox.  Note that only display text represented by the Text property can be edited; contents of the underlying ComboBoxItem elements cannot be edited directly. The following table lists available configurations.

IsEditable

IsReadOnly

Resulting Configuration

True

True

Contents of the ComboBox are selectable but not editable.

True

False

Contents of the ComboBox are fully editable.

False

Does not matter

Contents of the ComboBox are not editable or selectable (the default configuration).

Because IsReadOnly has a default value of false, the value of IsEditable can be used to enable or disable full editing and selection of ComboBox contents.  The value of IsReadOnly is typically only changed to enable a configuration in which the contents of the ComboBox are selectable, but not editable.

When IsEditable = false, the ComboBox uses a ContentPresenter to display the currently selected item; when IsEditable = 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.  When IsEditable = true and a selected ComboBoxItem includes non-plain text content, the ComboBox will display any TextSearch text for ComboBoxItem in lieu of the non-plain text content.

The following example shows a ComboBox with an editable TextBox. The IsReadOnly property is set to true therefore the user can not enter text into the TextBox.

<ComboBox Name="cb" Margin="10,10,3,3" Width="200" Height="30" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Top" 
             IsEditable="true" Text="Open Combo Box" IsReadOnly="true" 
             StaysOpenOnEdit="true" IsDropDownOpen="true">
        <ComboBoxItem>Spain - Item 0</ComboBoxItem>
        <ComboBoxItem>France - Item 1</ComboBoxItem>
        <ComboBoxItem>Peru - Item 2</ComboBoxItem>
        <ComboBoxItem>Mexico - Item 3</ComboBoxItem>
</ComboBox>

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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft