Documents
NextGrid & NextDBGrid
- Html Column Tutorial
- Upgrade existing projects for loading changes
- Edit events in NextGrid
- NextGrid Vista Style
- NextGrid How To
- Integrating Inplace Editors
- NextGrid Slide Style Tutorial
- InputLine Tutorial
- FieldChooser Tutorial
- Using Editors in runtime
- Grid Report Tutorial
NextGrid
- TreeColumn Tutorial
- NextGrid Quick Start
- Custom Draw in NextGrid
- Export to XML from NextGrid
- Optimize NextGrid
- NextGrid Custom Sorting
- VirtualColumn Tutorial
- Graphic Column Tutorial
NextDBGrid
- NextDBGrid Quick Start
- NextDBGrid Events
- NextDBGrid How To
- Sorting records in NextDBGrid
- LookupColumn Tutorial
NextInspector
- NextInspector Advanced tutorial
- ToolbarItem tutorial
- NextDBInspector Tutorial
- NextInspector Item Types
- Map VCL property to item
- NextInspector Quick Start
NextSheet
NextCollection
- NxAlertWindow Tutorial
- NxInfoPanel Tutorial
- Vista Styled Panels
- NxPathControl and NxNotebook tutorial
- NxPathControl Quick Start
- NxFlipPanel and NxHeaderPanel Quick Start
- NxOutlookBar Tutorial
- NxPageControl and NxNotebook Quick Start
- NxButton Tutorial
Misc
- Component Names Change
- NxComboBox styles
- Numeric FormatMask
- NxVirtualDataSet tutorial
- DateTime FormatMask
- NxPreview Quick Start
- 32bit Bitmaps Tutorial
- Quick update
- Enable typing unicode characters in InplaceEditors
- Using NxColorScheme
- NxProgress Tutorial
- NxAutoCompletion Tutorial
Labs
NextGrid .NET
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;