Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
Syndicate this content

Displaying a ComboBox to change the field's text value

This source code snippet requires TX Text Control .NET
Author:TX Text Control Support Department
Language:C#
Version:1.0
Released:December 05, 2006
Last modified:January 11, 2008
Requirements:TX Text Control .NET with Visual Studio 2003
Download code:tx_sample_dropdown_field.zip Download [8.25 KB, ZIP]

Displaying a ComboBox to change the field's text value

In another sample, we showed how to inherit from the TextField class to add new functionality to these fields. The same approach is used in this sample that illustrates how to display a ComboBox with possible options from which the user can choose.

Consider an application in which users should complete form fields. A ComboBox that displays all possible values is much easier for the user to select and much easier for the developer to validate.

The technique to inherit from the TextField base class is the same as in the above mentioned sample, so in this sample, we are only going to look at the specifics.

The class DropDownField consists of a new member: ListItems. This string array contains the strings that are displayed in the ComboBox, when the user double-clicks on a specific field. Every field should have a unique name to identify these 'special fields'. In the constructor, the parent TextControl object and the string array is passed:

  1. public DropDownField(TextControl TextControl, string[] ListItems)

On creating the new field, some events are attached to the parent TextControl object. On double-clicking the field, a ComboBox that has been added to the TextControl's Controls collection in the constructor's logic is displayed.

The ComboBox should be displayed exactly under the field. The position can be retrieved using the InputPosition class of TextControl. After selecting a specific value from the ComboBox, the text of the specific field is replaced and the ComboBox can be hidden again.

The sample requires Visual Studio 2003 and at least a trial version of TX Text Control .NET 13.0.

External verification page for ISO 9000:2000 certificate
ISO 9001:2000
certified