Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
TextSearch Class
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
TextSearch Class

Updated: November 2007

Enables a user to quickly access items in a set by typing prefixes of strings.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/xaml/presentation

Visual Basic (Declaration)
Public NotInheritable Class TextSearch _
    Inherits DependencyObject
Visual Basic (Usage)
Dim instance As TextSearch
C#
public sealed class TextSearch : DependencyObject
Visual C++
public ref class TextSearch sealed : public DependencyObject
J#
public final class TextSearch extends DependencyObject
JScript
public final class TextSearch extends DependencyObject
XAML
<p>
                    You cannot declare this managed class in XAML, but you can use its static properties to assign values in XAML.
                </p>

This class is used to assign a string to items in a control's collection. Assigning a string to each item in the collection accomplishes two objectives. It specifies the text to display when the item is selected, and it enables the user to select an item by typing the assigned string.

For example, assume that a ComboBox contains a collection of Image objects, one of which is an image of a dog. If you assign the string, "Dog" to that item, the user can select the dog by typing the word in the combo box's text box. As soon as the user types enough of the word to distinguish it from other items in the selection, the image of the dog will be selected. If IsEditable is set to true on the ComboBox, "Dog" will appear in the text box.

You can specify the text that identifies an item by using the TextSearch..::.TextPath property on a control or by setting the Text property on each item in the control's collection. Setting one of these properties ensures that unexpected text is not displayed. If you set the Text property on a control's collection item, the TextPath property will be ignored. If you set the TextPath property to a value that is not the name of an actual property, TextPath is ignored.

The following examples create ComboBox controls that contain images as items instead of text. Functionally, the examples are the same. The first example sets the TextPath property on the ComboBox and the second example sets the Text property on each item in the collection.

C#
<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>

C#
<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>

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows Vista

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker