Skip to main content

Master-Detail Tutorial. Step 5: Specifying Editors for Items

  • 3 minutes to read

Assigning editors to items allows the end-user to edit dataset fields in a more convenient way. In this section, editors are assigned to three items:

  • a radio group (TcxRadioGroup) is assigned to the GENDER column in the tvPersons View

  • a lookup editor (TcxLookupComboBox) is assigned to the PERSONID column in the tvStaff View

  • an image editor (TcxImage) is assigned to the SCREEN row in the cvFilmScreens View

To assign editors to items in this tutorial, use the Properties property.

Note

to specify the editor via code, you should use the PropertiesClass property as well. Refer to the Data Editing Using Inplace Editors section for details.

  1. Activate the Component Editor and click the tvPersons box on the Structure panel and this displays the View’s columns on the right. Select the tvPersonsGENDER item (the name for the GENDER column) in the list and switch to the Object Inspector and this should now display the properties of the item.

Set the column’s Properties property to RadioGroup by selecting the corresponding value from the dropdown list:

Now expand the Properties property and click the ellipsis button in the Items value box. This opens a standard collection editor where we can now add items:

Add two items by clicking the button twice. Items will be used to represent the male or female sex of a person. Set the Caption property of the first item to Male and the Value property to True.

For the second item, set the Caption property to Female and the Value property to False.

The following image shows a cell from the GENDER column with a radio group specified as an editor:

  1. The tvStaffPERSONID column contains numerical identifiers of persons from the PERSONS table. It corresponds to the ID column from this table, thus allowing you to specify the lookup combo box as an editor. Instead of the person identifier, the editor will display the person’s name in the edit box. The dropdown window of the lookup will display the first and the second name of the person.

Display the properties of the tvStaffPERSONID column of the tvStaff View in the Object Inspector as shown above. Set its Properties property to LookupComboBox. Then set the attributes of the Properties object as follows:

This sets the source of records displayed in the dropdown and in the edit box of the lookup combo box.

The ListFieldNames property identifies fields displayed in the dropdown of the lookup editor.

The KeyFieldNames property specifies the field(s) used to identify records from ListSource. The values of this field must match the values of the current column (tvStaffPERSONID).

This sets the width of the dropdown window.

The ListFieldIndex addresses the column in the dropdown to display in the edit box. The value of the property defines a zero-based index of a field within the ListFieldNames list. ListFieldIndex is set to 1 and so addresses the SECONDNAME field.

The following image shows a lookup editor assigned to the tvStaffPERSONID column:

  1. For the SCREEN item of the cvFilmScreens View, set its Properties property to Image. Then set the item’s properties to the following values:

Graphics provided by the dataset field are interpreted as JPEG images.

This stretches the image to accommodate the size of cells.

See Also