ComponentOne True DBGrid Pro 8
Tutorial 26 - Value Translation

In this tutorial, you will learn how to use the Value Translation feature. Using this feature, you can connect a TDBG dropdown control to a table which contains a value and representation and the drop-down will automatically map the representation to the value.

  1. Start a new project.

  2. From the Visual Basic Project menu, select Components, then check the boxes labeled ComponentOne True DBGrid Pro 8.0 (OLEDB) and Microsoft ADO Data Control (OLEDB).

  3. Place two ADO Data controls, a True DBGrid control and a True DBGrid Dropdown control on the form. The form should look similar to this:

  4. Next we will connect Adodc1 to the TDBG8Demo database.

    Display the custom property pages for Adodc1. Click the General tab and select the Use Connection String option. Click Build. Choose the Microsoft Jet 4.0 OLE DB Provider option. Click Next. Enter the datasource name by pressing the Ellipsis button (…) and locating the database (TDBGDEMO.MDB). Test the connection to make sure it works. Press OK to close the dialog window. Press the Apply button.

    • Choose the Recordsource tab. Set the Command Type to 2 – adCmdTable and the Table or Stored Procedure Name to Customers. Press the OK button to accept the selections and close the properties page.

  5. Next we will connect Adodc2 to the TDBG8Demo database using the same method we used in the previous step. After testing the connection and pressing the Apply button, choose the Recordsource tab. Set the Command Type to 2 – adCmdTable and the Table or Stored Procedure Name to CustType. Press the OK button to accept the selections and close the properties page.

  6. Set the TDBGrid1 DataSource to Adodc1 and TDBDropDown1 DataSource to Adodc2.

  7. Retrieve the fields for TDBGrid1 by right clicking within the grid and choosing Retrieve Fields from the context menu.

  8. Retrieve the fields for TDBDropdown1 by right clicking within the grid and choosing Retrieve Fields from the context menu. The form should be similar to this:

  9. Go to the TDBDropdown1 properties page and set DataField property to TypeID, the ListField property to TypeDesc and the ValueTranslate property to True.

  10. Go to the TDBGrid1 properties page and choose the Splits tab. Expand the Splits(00) tree, then the Columns tree then the Columns(06) [CustType] tree. Set the Order property to 1, the AutoCompletion property to True, the AutoDropdown property to True and the Width property to 1300. Press Apply.

  11. Choose the General tab in TDBGrid1 properties page. Expand the Columns tree then the Columns(06) [CustType] tree. Set the DropDown property to TDBDropdown1. Press OK to accept the changes and close the property pages.

  12. Go to the TDBDropdown1 properties. On the General tab, expand the Columns tree then the Columns(00) [TypeID] tree. Set the Visible property to False. Press OK to accept the changes and close the property pages.

Run the program and observe the following:

TDBGrid’s Value Translation has mapped the customer type and the type description drop-down with the customers table.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback