Export (0) Print
Expand All

ComboBox.IsEditable Property

Gets or sets a value that enables or disables editing of the text in text box of the ComboBox. 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 IsEditable { get; set; }
/** @property */
public boolean get_IsEditable ()

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

public function get IsEditable () : boolean

public function set IsEditable (value : boolean)

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

Property Value

true if the ComboBox can be edited; otherwise false. The default value is false.

Identifier Field

IsEditableProperty

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. This is thedefault 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 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.  When IsEditable is equal to 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 examples create ComboBox controls that contain images as items instead of text. If the IsEditable property is set to true nothing is displayed when one of the images is selected. To avoid a blank TextBox or a TextBox with unexpected text use the TextSearch properties, Text and TextPath to assign text to be displayed.

<ComboBox IsEditable="true" TextSearch.TextPath="Name">
      <Image Name="Cat" Source="data\cat.png"/>
      <Image Name="Dog" Source="data\dog.png"/>
      <Image Name="Fish" Source="data\fish.png"/>
</ComboBox>

<ComboBox IsEditable="true">
      <Image TextSearch.Text="Cat" Source="data\cat.png"/>
      <Image TextSearch.Text="Dog" Source="data\dog.png"/>
      <Image TextSearch.Text="Fish" Source="data\fish.png"/>
</ComboBox>

Another solution is to use the DisplayMemberPath property. The drop-down control of the ComboBox will not display the images but will display the text you assigned.

The following example shows how to use DisplayMemberPath.

<ComboBox IsEditable="true" DisplayMemberPath="Name">
      <Image Name="CAT" Source="data\cat.png"/>
      <Image Name="DOG" Source="data\dog.png"/>
      <Image Name="FISH" Source="data\fish.png"/>
</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

Community Additions

ADD
Show:
© 2014 Microsoft