LookupColumn Tutorial

Related Articles:

Info
  • Skill:
  • Version: 1.0.1
  • Authod: Bojan Nikolic
  • Created:
  • Updated: 2008-04-22

Introducing



With using Lookup Column we can combine Fields of 2 Tables or Queries to get result similiar when using SQL Join commands.

Sometime we need to represent Field from first table with using Values from second Field. To do this, we need to link this 2 Fields with using properties from TNxLookupColumn.

TNxLookupColumn is located at the secong "Tab" inside Next DBGrid Columns Editor.

Example Tables



In this example we have 2 tables: Articles and ArticleTypes.

We need to link ArticleTypeId Field from first Table to Id Field from second Table.



Set Lookup Column



Now, we will set TNxLookupColumn:

1. Place 2 TTable (TADOTable, TIBTable, TZTable...) components and 2 TDataSource components on form.
2. Place NextDBGrid on Form and add one TNxLookupColumn.
3. Select this column and set next properties
4. Property FieldName will be set as usual to desired Field from first table - "ArticleTypeId"
5. Property KeyFieldName - Key Field from ArticleTypes Table. This property will have "Id" as Value.
6. ListDataSource - Set to second DataSource
7. ListFieldName - Set to displaying Field from second Table. In our case is "Name".

Was This Article Useful?

Only constructive comments, code contributions... will be publishes. Questions, non-official discussion will not be published.