Documents
NextGrid & NextDBGrid
- Integrating Inplace Editors
- Upgrade existing projects for loading changes
- Grid Report Tutorial
- FieldChooser Tutorial
- Using Editors in runtime
- 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
- Export to XML from NextGrid
- NextGrid Custom Sorting
- TreeColumn Tutorial
NextDBGrid
- Sorting records in NextDBGrid
- NextDBGrid Events
- NextDBGrid Quick Start
- NextDBGrid How To
- LookupColumn Tutorial
NextInspector
- NextInspector Item Types
- NextInspector Quick Start
- NextDBInspector Tutorial
- NextInspector Advanced tutorial
- ToolbarItem tutorial
- Map VCL property to item
NextSheet
NextCollection
- NxInfoPanel Tutorial
- Vista Styled Panels
- 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
- NxVirtualDataSet tutorial
- Component Names Change
- 32bit Bitmaps Tutorial
- Quick update
Labs
NextDBGrid How To
Related Articles:
Info
- Skill:
- Version: 1.0.0
- Author: Bojan Nikolic
- Created: 2009-07-25
- Updated: 2009-08-26
Content:
1. Using OnApplyCell event
2. Display Cell Hint
3. Display content of Memo Field
4. Get content from DataSet outside Grid's buffered records scope
1. Using OnApplyCell event
While cell is rendered on screen, NextDBGrid read Field's value associated with FieldName property.
With using OnApplyCell event, cell value may be additionally adjusted.
In this example value (AsFloat) from Field property of 1st column is read and parameter Value is set for 2nd column (ACol = 1).
procedure TForm1.NextDBGrid1ApplyCell(Sender: TObject; ACol, ARow: Integer;
var Value: WideString);
begin
if ACol = 1 then
begin
if NextDBGrid1.Columns[0].Field.AsFloat > 10000 then
begin
Value := '2';
end else
if NextDBGrid1.Columns[0].Field.AsFloat < 10000 then
begin
Value := '1';
end else Value := '0';
end;
end;
2. Display Cell Hint
With using OnCellHint event custom hint message may be displayed when user move mouse over cell.
procedure TForm1.NextDBGrid1CellHint(Sender: TObject; ACol, ARow: Integer;
var Value: WideString);
var
Field: TField;
begin
if ACol = 1 then
begin
Field := NextDBGrid1.Columns[0].Field;
Value := 'OnCellHint' #13#10 'This cell have own hint from OnCellHint event.';
end;
end;
3. Display content of Memo Field
By default MemoField display Memo Field as "(MEMO)" string. NxDBMemoColumn having possibility to display Memo Fields in full.
| Name | Meaning |
|---|---|
| mdDefault | Display Memo Field as (MEMO) string |
| mdContent | Display full content of Memo Field |
4. Get content from DataSet outside Grid's buffered records scope
function TForm1.GetFieldValue(DataSet: TDataSet; ACol, ARow: Integer): WideString; var B: TBookmark; begin DataSet.DisableControls; B := DataSet.GetBookmark; DataSet.First; DataSet.MoveBy(ARow); Result := DataSet.Fields[ACol].AsString; DataSet.GotoBookmark(B); DataSet.EnableControls; end;
To fill list with selected rows from grid, use next code:
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
ListBox1.Clear;
for i := 0 to NextDBGrid1.RowCount - 1 do
begin
if NextDBGrid1.Selected[i] then
ListBox1.Items.Add(GetFieldValue(ADOTable1, 1, i));
end;
end;