Documents
NextGrid & NextDBGrid
- Integrating Inplace Editors
- Upgrade existing projects for loading changes
- FieldChooser Tutorial
- NextGrid How To
- Html Column Tutorial
- NextGrid Slide Style Tutorial
- InputLine Tutorial
- Edit events in NextGrid
- NextGrid Vista Style
NextGrid
- NextGrid Quick Start
- Graphic Column Tutorial
- Optimize NextGrid
- Custom Draw in NextGrid
- VirtualColumn Tutorial
- NextGrid Custom Sorting
- TreeColumn Tutorial
NextDBGrid
- NextDBGrid Events
- NextDBGrid Quick Start
- LookupColumn Tutorial
NextInspector
- NextInspector Item Types
- NextInspector Quick Start
- NextDBInspector Tutorial
- NextInspector Advanced tutorial
- Map VCL property to item
NextSheet
NextCollection
- NxInfoPanel Tutorial
- NxPathControl and NxNotebook tutorial
- NxAlertWindow Tutorial
- NxPathControl Quick Start
- NxButton Tutorial
- NxOutlookBar Tutorial
- NxFlipPanel and NxHeaderPanel Quick Start
- NxPageControl and NxNotebook Quick Start
Misc
- DateTime FormatMask
- NxAutoCompletion Tutorial
- Using NxColorScheme
- NxComboBox styles
- Enable typing unicode characters in InplaceEditors
- NxProgress Tutorial
- NxPreview Quick Start
- Numeric FormatMask
- Component Names Change
- 32bit Bitmaps Tutorial
Labs
NextDBGrid Events
Related Articles:
Info
- Skill:
- Version: 1.0.1
- Author: Bojan Nikolic
- Created:
- Updated: 2008-04-22
OnApplyCell
This event occur when conten't value are goin to be drawn. Value is first reaeded from TField and then drawn. Between this 2 process OnApplyCell event occur and we may set that other value is drawn than one from TField.
| Name | Type | Meaning |
|---|---|---|
| ACol | Integer | Indicate Column Index of currently drawing cell. |
| ARow | Integer | Indicate Row Index of currently drawing cell. |
| Value | WideString | Determine or specify cell's drawing value. |
Usual scenario for using this event is reading Value parameter and adjust it additionally.
Another way may be using Field property (TField) of currently drawing column access to it and adjust Value parameter.
procedure TForm1.NextDBGrid1ApplyCell(Sender: TObject; ACol, ARow: Integer;
var Value: WideString);
var
Field: TField;
begin
Field := NextDBGrid1.Columns[ACol].Field;
if Field <> nil then
begin
if Field.AsString = '' then Value := '';
end;
end;
OnColumnCreate
This event occur when DataSet is activated and columns are added (doAddColumns flag must be True in DataAwareOptions). This is Point where class of newly added Column can be changed. Also adding column can be canceled.
Parameters:
| Name | Type | Meaning |
|---|---|---|
| Field | TField | Indicate TField in progress. When DataSet is activated, Next DBGrid add one column and occur this event for each TField in DataSet. |
| ColumnClass | TNxDBColumnClass | Column class of newly added Column. Using this parameter, column type can be changed. |
| AddColumn | Boolean | Default is True. When is set to False, column will NOT be added. |
As this event occur for each TField from DataSet when is activated, we may decide which field will have own column with grid, or change type of column. For example if default column are goin to be added TNxDBNumberColumn we may set ColumnClass property to be TNxDBImageColumn instead.
procedure TForm1.NextDBGrid1ColumnCreate(Sender: TObject; Field: TField; var ColumnClass: TNxColumnClass; var AddColumn: Boolean); begin if Field.FieldName = 'Progress' then ColumnClass := TNxDBProgressColumn; if Field.IsBlob then AddColumn = False; // Don't add column for BLOB fields end;
If AddColumn = True, [/code]OnColumnAdded[/code] event will occur next for this columns.
OnColumnAdded
This event occur when new Column is added after DataSet is activated. This is Point where new Column may be additionaly customized.
Parameters:
| Name | Type | Meaning |
|---|---|---|
| Column | TNxDBCustomColumn | Indicate newly added column. |
procedure TForm1.NextDBGrid1ColumnAdded(Sender: TObject;
Column: TNxDBCustomColumn);
begin
if Column is TNxDBCheckBoxColumn then
begin
with Column as TNxDBCheckBoxColumn do
begin
Alignment := taCenter;
ValueChecked := 'True';
ValueUnchecked := 'False';
Width := 50;
end;
end;
end;
In this example we have customize newly added CheckBox Column.
OnMeasuringRowHeight
This event occur in Cells drawing process, when Grid need to acquire Row Height. Default Value for each row is equal to property RowSize, but with using this event Row Height can be additionaly adjusted.
| Name | Type | Meaning |
|---|---|---|
| Index | Integer | Indicate Index of Row being drawn. |
| RowHeight | Integer | Gets or Sets Row Height of current Row. |
procedure TForm1.NextDBGrid1MeasuringRowHeight(Sender: TObject; Index: Integer; var RowHeight: Integer); begin if Index = 5 then RowHeight := 45; end;