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
NextGrid How To
Related Articles:
Info
- Skill:
- Version: 1.0.0
- Author: Bojan Nikolic
- Created:
- Updated: 2008-06-01
How to add Column in run-time?
First add next code in uses section:
uses NxColumns, NxColumnClasses;
Then call Add method of Columns property. Add method require that you specify Column Class for new column (TNxTextColumn, TNxNumberColumn, TNxDateColumn...). Next line will add one TNxTextColumn:
NextGrid1.Columns.Add(TNxTextColumn);
NextGrid1->Columns->Add(__classid(TNxTextColumn))
or we can add one TNxDateColumn:
NextGrid1.Columns.Add(TNxDateColumn);
NextGrid1->Columns->Add(__classid(TNxDateColumn))
Use same method for all Column types (TNxNumberColumn, TNxImageColumn...)
How to access column type specific properties with typecasting
TNxComboBox(NextGrid1.Columns[0]).DropDownCount = 4;
(TNxComboBoxColumn*)NextGrid1->Columns[0]->DropDownCount = 4;
How to paint each second row in different color?
In NextGrid, you can set color for any Cell with:
NextGrid.Cell[Col, Row].Color := clRed;
NextGrid->Cell[Col][Row]->Color = clRed;
But, you can do this also with OnCellColoring event.
if not(csSelected in CellState) then begin if ARow mod 2 = 0 then CellColor := $00F5FCFE; end;
if(CellState.Contains(csSelected)) { if (ARow % 2 = 0) { CellColor := $00F5FCFE; } };
How to format number when displaying cell?
Add TNxNumberColumn, and to specify FormatMask property. To see what you can put into this property look FormatFloat property in Delphi Help.
Examples:
Format string- 1234 -1234 0.5 0 1234 -1234 0.5 0 0 1234 -1234 1 0 0.00 1234.00 -1234.00 0.50 0.00 #.## 1234 -1234 .5 #,##0.00 1,234.00 -1,234.00 0.50 0.00 #,##0.00;(#,##0.00) 1,234.00 (1,234.00) 0.50 0.00 #,##0.00;;Zero 1,234.00 -1,234.00 0.50 Zero 0.000E 00 1.234E 03 -1.234E 03 5.000E-01 0.000E 00 #.###E-0 1.234E3 -1.234E3 5E-1 0E0
How to get column with links?
Insert one TNxTextColumn, click on this column in editor and in Font property, set Style sub-property to fsUnderline, also set Font.Color to clBlue. Then set Cursor property to crHandPoint.
If you want to show system Hand Point cursor, instead of Delphi Hand Point cursor insert next code in OnCreate event of main form:
var C: HCURSOR; begin C := LoadCursor(0, IDC_HAND); if C <> 0 then Screen.Cursors[crHandPoint] := C; end;
Then, if you want to do something when user click on link you need to insert code in OnSelectCell event. In this event, simply check ACol and ARow parameter and do some action.
if ACol = 4 then begin NextGrid1.DeleteRow(ARow); end;
How to hide focus rect in NextGrid?
Simply set flag aoHideFocus in AppearanceOptions property to True and NextGrid will not display doted rectangle around selection.
How to add several cells with one command
Use AddCells method which add array of cells and add new rows if is necessary.
Example:
NextGrid1.AddCells(['Cell 0', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4']);
4.4 There is also overloaded version which add cells into one specified column.
NextGrid1.AddCells(['Cell 0', 'Cell 1', 'Cell 2', 'Cell 3', 'Cell 4'], 2);
Comments
2008-06-15 14:43:44
The article was useful, but I could really use some good documentation. Right now I'm converting my project from one that uses a number of TStringGrids to one that uses NextGrids, and I'm having trouble finding the equivalents of TopRow, Col, etc.
Thanks, Mike
Thanks, Mike
2015-05-16 17:09:47
how to add button to TNextGrid i'm so tired to find this on your Demos or your WebSite Tutorial ?
2015-05-16 18:04:14
Hi,
For version 5, you can use custom drawing (more at: http://dn.bergsoft.net/custom-draw-in-nextgrid.htm).
In version 6 there is a Button property for Icon Colunn, and there is a ToolbarColumn with array of buttons.
For version 5, you can use custom drawing (more at: http://dn.bergsoft.net/custom-draw-in-nextgrid.htm).
In version 6 there is a Button property for Icon Colunn, and there is a ToolbarColumn with array of buttons.