Software
Delphi and Lazarus
Trekking and Events
Blog and Forum
Čeština English
Main menu
Delphi and Lazarus
Useful Links

interesting webs & galleries of my friends:

F-Web

Máša&Pája Gallery

Delphi and Lazarus:

Embarcadero/ CodeGear

Lazarus project

Torry's Delphi pages

JEDI Code Library

 

KGrid

There were several reasons for me to write an own grid component for Delphi:

- Borland's inoperability to fix reported bugs (this applied not only for TStringGrid)

- I wanted different editing controls like TEdit, TComboBox, TCheckBox to be inserted in cells

- I wanted the last column to be aligned within the client area edge

- I wanted a slightly better behavior while moving or resizing columns or rows

Now KGrid has a lot of features and is becoming a versatile solution for table visualisations, table data modifications and creating table reports under Delphi and Lazarus IDEs. Everything is provided royalty free and with complete source code (however, it is copyrighted software, more information about the license can be found in the header of each source file).

KGrid features
Written as TCustomControl descendant, this is not a TCustomGrid enhancement
95% compatible with TDraw(String)Grid
Any TWinControl descendant can be used as inplace editor.
Cell clipping and double buffering
Cell merging and splitting. Robust and versatile solution.
Column/row/grid autosizing
Contains the database control TKDBGrid
Cross platform solution in Lazarus
Each color can be modified at design time
Editable/selectable fixed cells
Index mapping - a technique that greatly simplifies event handling when columns and/or rows change their positions
Last column or row can be aligned - corresponding scroll bar will not appear
OS themes fully supported including Windows Vista/7 themes
Printing and previewing. Robust solution. On the fly previewing - changes to the grid are instantly previewed. Printing a table in Delphi has never been easier.
Row and column hiding with optional visual indication
Rows, columns and cells (optional) are implemented as classes
Several styles for moving and resizing of rows or columns
Single source and the same functionality in both Delphi and Lazarus
Unicode component. For ANSI Delphi versions (up to 2007) no unicode inplace editors are available - you must take these somewhere else (e.g. from TMS Unicode controls).
Various text output attributes (works on all platforms)- multiline text, end ellipsis, path ellipsis, word break
Versatile cell painting interface (drawing cells with various attributes, thumbnail/image cells, checkbox cells,...)
Versatile design of cell events
Versatile sorting interface
Virtual grid possibility - data will not be stored in the grid directly but somewhere else in the application

Necessary packages

From version 1.3 none. Up to version 1.3 beta JEDI Code Library (JCL) - Version 1.100+ - download here.

Compiled executable demo

Download the demo executables (Delphi only) directly without compiling in Delphi: KGridDemos.zip

KGrid downloads

Note: there are only stable packages here. For latest changes and hotfixes please download KControls.

FileVersionNumber of
downloads
Available tools:Changes
N/Ahigher than 1.7N/AN/ANewer versions available only in KControls package
kgrid_1.7.zip1.73410Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+update for RAD Studio XE, editable fixed cells, Vista style selection
9.12.2010 important patch
kgrid_1.6.zip1.61123Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+column/row/grid autosizing and many other improvements and bugfixes
kgrid_1.5.zip1.51635Delphi 6+,Lazarus 0.9.29(SVN#21827)+tiny modifications due to releasing KControls
kgrid_1.5beta.zip1.5 beta173Delphi 6+,Lazarus 0.9.29(SVN#21827)+printing and previewing (Lazarus only Win32), drawing thumbnail/image cell
kgrid_1.4.zip1.4631Delphi 6+,Lazarus 0.9.29(SVN#21827)+full Lazarus support (all widget sets), database control TKDBGrid, cell merging/splitting, smooth scrolling and much more. 3.10.2009 hotfix: painting performace increased (QT, GTK2). 4.10.2009 hotfix: PgUp/PgDn key fix, new minor options in TKDBGrid
KGrid_1.3.zip1.3608Delphi 6+,Lazarus 0.9.26+doesn't need JCL, port to Lazarus(Win32), ThroughClick property, text output attributes.
KGrid_1.3beta.zip1.3 beta150Delphi 6+Column/row visibility, more sorting styles & other fixes.
KGrid_1.2.zip1.22461Delphi 6+Update for Delphi 2009, minor fixes, OnChanged event, documentation update
22.10. hotfix for Delphi6-7
KGrid11.zip1.11437Delphi 6 till 2007Sorting interface, cell clipping and double buffering, TKGridCellPainter class, another improvements and fixes, documentation update
KGrid10.zip1.01021Delphi 6 till 2007Index mapping, demo, finished documentation, many bugfixes and improvements
KGrid09.zip0.9271Delphi 6 till 2007Initial release

Screenshots (click the images to enlarge)

 
Simple KGrid demonstration programArbitrary TWinControl descendant can be used as inplace editor
 
Cell merging, TKGridAttrTextCell demoPrint preview
 
Disabled gridDocumentation preview
 
Main demo in Lazarus/Linux (GTK2)Advanced header demo in Lazarus/Linux (GTK2)
Simple database demo in Delphi/Windows XP
 

Home | Software | Delphi and Lazarus | Trekking, travelling | Sport | Others | Blog

Search in comments: 
inserted: 2012-04-10 21:30:23   Reply...
From: mtbf40
Hello, how can I write bold text in single cells? example: c1-Info1(bold) c2-Info1_1 c3-Info1_2 c4-Info1_3 c5-Info2 (bold) c6-Info2_1 c7-Info2_2 c8-Info2_3
inserted: 2012-04-08 17:34:49   Reply...
From: Donato
Does anyone have a simple example of how to use the TCheckBox TKgrid? Alguém teria um exemplo simples de como utilizar Tcheckbox no TKgrid?
inserted: 2012-04-04 10:46:53   Reply...
From: kucing
When using TComboBox as in place editor, the drop down list does not show up. One of the workaround is by using "xpman.res", but this cause display issue on Windows 7. Please if you can fix this on the next version. Thank you.
inserted: 2012-03-29 13:48:47   Reply...
From: MilorD
Good day! I wanted to know whether a component KGrid for Embarcadero RAD Studio XE 2. I would very much like to. Thank you.
inserted: 2012-03-30 09:22:42   Reply...
From: tk
Yes I will upgrade the component pack to XE 2 soon.
inserted: 2012-01-21 13:08:51   Reply...
From: carre
Hi, i try to change the color of a cell (based on demo) - with TKGridAttrTextCell(Analyse_KGrid1.Cell[cellrow,cellcol]) do begin Text := 'No Problem'; Brush.Style := bsSolid; Brush.Color := RGB(128 + Random(127), 128 + Random(127), 128 + Random(127)); end; Text statement is without a problem but on the Brush statement Lazarus rise a external exception SIGSEGV - any idea?
inserted: 2012-01-22 11:01:45   Reply...
From: carre
I found my fault (register custom cell class was missing).
inserted: 2012-01-19 13:34:27   Reply...
From: gwiethaus
Bug Detected: Delphi 2007 Windows 7 Professional 64 bit. The object instance is not set FCells. It happens when I use the method Objects []. TKCustomGrid.SetObjects shoots, but FCells is not set. So my objects can not be linked with the cell. The code is below. //in showform event KGrid1.Objects[1,1]:= Combobox1; //in KGrids.pas (KControls Package) procedure TKCustomGrid.SetObjects(ACol, ARow: Integer; Value: TObject); var Cell, Tmp: TKGridCell; begin //Bug Here in FCell do not is set, FCells = nil if Assigned(FCells) and ColValid(ACol) and RowValid(ARow) then begin FlagSet(cGF_GridUpdates); ... ... end; Sincerely, Guilherme Wiethaus, São Paulo / Brazil
inserted: 2012-01-04 14:26:38   Reply...
From: PicoDeP
Thank you for sharing your component! I only modified the following code because I think that VisibleColCount and VisibleRowCount don't work propertly: function TKCustomGrid.GetVisibleColCount: Integer; begin Result := LastVisibleCol - FTopLeft.Col + 1; end; function TKCustomGrid.GetVisibleGridRect: TKGridRect; begin Result := GridRect(FTopLeft.Col, FTopLeft.Row, LastVisibleCol, LastVisibleRow); end; function TKCustomGrid.GetVisibleRowCount: Integer; begin Result := LastVisibleRow - FTopLeft.Row + 1; end;
inserted: 2011-11-28 11:42:02   Reply...
From: jani
Seems good component, but i really cant install it or compile demos. I have Delphi 5 and the error i get is "line to loong" for kcontrols.inc. How can i fix it ?
inserted: 2011-10-25 09:29:44   Reply...
From: christensen
Hi, amazing component, thanks! Now my problem:i want to display checkbox in the kgrid, the bd is Fifebird 2.1.3(smallint type field stores the boolean values:0 and 1) How can i display the content of this type of fields in kgrid, but with checkboxes? Thanks
inserted: 2011-10-05 18:00:25   Reply...
From: kalagan
If I set property ScrollBars to ssVertical (or ssHorizontal) at design time, scrollbars are not displayed as expected (both are not visible). How can I do to always show scrollbars?
inserted: 2011-10-05 17:56:04   Reply...
From: kalagan
How can I have a grid with 0 rows? If I set rowcount:=0 it doesn't work.
inserted: 2011-09-12 22:45:09   Reply...
From: Anzo
I have a problem with TKdbGrid. I have dataset with several fields, and TKdbGrid draw column for each field. But I`m want draw only one of them. Please show me little snippet of TKdbGrid header/column config.
inserted: 2011-09-10 13:11:46   Reply...
From: Robert
How can i print the KGrid without fix number column. can printview like dbgrideh
inserted: 2011-09-09 10:02:06   Reply...
From: xcod
In TDBGrid by pressing the cursor down a new row added. In TKDBGrid not added. Why?
inserted: 2011-09-01 00:05:26   Reply...
From: Rass87
Hello everyone, I just installed the KGrid package on Lazarus (v 0.9.30) and I have a little problem (?): I can't edit the fields of my grid at all. I mean I assumed that the columns of these grid components can be edited the same way as the common DBGrid's: double-click it in the designer and the column editor opens. Instead of this, I only get an OnClick event handler procedure created as a result. Could someone tell me what am I doing wrong here please? :)
inserted: 2011-08-25 00:17:13   Reply...
From: vovach777
OnSelectionExpand property do not work on 1.7 release of KGrid
inserted: 2011-07-21 07:07:52   Reply...
From: DsLin
KGrid is a very nice control. Thanks a lot for your contribution. Now, I want to output some multiline text in a cell, and I found that there is no LineSpace attribute in CellPainter, so I suggest to add this attribute to CellPainter, it will greatly make long length text more beautiful. It's code may like this in below: (procedure Initialize is subprocedure of procedure DrawAlignedText() in KGraphics.pas) procedure Initialize; begin ClipRect := ARect; InflateRect(ClipRect, -HPadding, -VPadding); DC := Canvas.Handle; FontHeight := GetFontHeight(DC) + LineSpace; //Here is the key point end;
inserted: 2011-06-25 14:03:30   Reply...
From: hairdresser
Dobrý den.... Potřebuji obarvit buňku po stisku tlačítka... Zkoušel jsem téměř vše
inserted: 2011-06-08 21:38:27   Reply...
From: Stuart
I'm not a great programmer so please bear with me. I'm trying to make a tiny sudoku application and only need for it to display nicely. The KGrid is much better than the default grids and I'm sure it is perfect but I need to get more out of it. How can I change the font color in individual cells without changing the font color in all other cells?
inserted: 2011-11-05 08:50:16   Reply...
From: Suren Sarathkumara
In OnDrawCell event if (ACol = x) and (ARow = y) then KGrid1.CellPainter.Canvas.Font.Color := $ABABAB;
inserted: 2011-05-18 13:55:00   Reply...
From: Matt
Hi! I've been using your KGrid component for a while and I like it very much. But now it seems I have found a bug. I use Delphi XE. I put only KGrid on the Form and enable sortable columns. Now when I compile the application, column sorting works fine if I run application on Windows 7, but when I run it under Windows XP the whole application freezes (and has to be shut down with Task Manager). Can you tell me how to fix this so my application will work under Windows XP? Best regards, Matt
inserted: 2011-05-19 09:07:30   Reply...
From: Matt
I made a mistake. The problem is not with column sorting, but with column moving. Application freezes when I try to move column (when using KGrid, compiling on Delphi XE and running under Windows XP).
inserted: 2011-05-31 11:19:01   Reply...
From: Matt
Has anybody been able to find a fix for this? Any workarounds?
inserted: 2011-12-04 10:14:15   Reply...
From: Tulkas
I have the same problem with Delphi7 and Windows XP. Solved changing property DragStyle to dsLine or dsXORLine.
inserted: 2011-09-09 15:16:33   Reply...
From: truetom
I have same problem.
inserted: 2011-05-15 12:41:57   Reply...
From: batozai
halo i have tried it for hours, but i didn't figure it out. i used to use TAdvstringgrid from TMS component in delphi. now i use TKGrid. i need to know how to acces inplaceditor event on kgrid component. i have add a tbutton to a grid column, now i want to acces the onclick event of the button. i also add an edit component as inplace editor, now i want to acces the onchange event of the edit component..... how do i do that ? may later i will add another tcontrol component as inplace editor...... thanks in advance
inserted: 2011-05-15 22:22:21   Reply...
From: tk
In KGrid you have to write the handler yourself and assign it to the inplace editor in code.
inserted: 2011-05-16 02:51:36   Reply...
From: batozai
hi tk can you please give me example how to make the handler...? i have made a procedure that i want to call when the button is clicked. also when the combobox is click.... from what event of kgrid i should handle this ? thanks in advance
inserted: 2011-04-14 19:55:56   Reply...
From: Philips10
Using KControls Development Suite under Lazarus: Will the application I use it to program with be cross-platform (Mac Linux, OpenBSD/UNIX, Windows) compatible? Since the package (as I need KGrid in partic.) uses the Jedi package I begun to have some doubts, though you wrote on your site "Cross platform solution in Lazarus". Another question: I guess I can use the ZeosLib with eg PostgrSQL or SQLite? That must be the case too! Had no tine to try it out... Thank you very much in advance.
inserted: 2011-04-15 12:21:06   Reply...
From: Philips10
..those were not so clever questions to ask for real... But I have a request: Could you please program a footer to your 1st class K(DB)Grid for financial applications? Please work on this, will you? I really need that bonus! A big thanks in advance!
inserted: 2011-04-16 21:24:00   Reply...
From: tk
Hi I am out of time these months. Volunteers are welcome to put KComponents to some other place managed by SVN/CVS. This means NOT that I won't be able to continue this development but for this year you cannot expect much progress. Because of that it is better for these components to become open source.
inserted: 2011-04-22 21:23:07   Reply...
From: sourceforge.net
Some other place as an open source-project with SVN (better than CVS) - repr.? www.sourceforge.net would be the best place to put it. Right now, I have started with my acounting studies, so I won't be having much time to "guard over" your KGrid. Becides..it would be not to "cool" of me to take over your work. Fa more developers would be working with and for KGrid. You could eg give some ideas to those (like that footer,...) Great idea!
inserted: 2011-04-13 19:22:53   Reply...
From: martinrame
Hi TK. Do you plan to add SVN/Git access to the development tree?. I'm sure there are some people interested in sending fixes/improvements to the component.
inserted: 2011-04-16 21:18:14   Reply...
From: tk
I am sorry but I am out of time these months. Anybody is welcome to give KComponents to a SVN managed location.
inserted: 2011-03-31 03:01:52   Reply...
From: Daniel
HI! Thanks for so faboulus component! I have 2 qustions. It is possible to make a transparent grid? it is possible to draw my own Scrollbar? THanks a lot! Daniel
inserted: 2011-04-16 21:16:57   Reply...
From: tk
You need to adapt cell painting chain or scrollable window behavior.
inserted: 2011-03-05 15:38:50   Reply...
From: zhlmxh
Does KGrid support Footer? If not, are there plans to add this?
inserted: 2011-03-05 19:00:00   Reply...
From: tk
No, at least from my part.
inserted: 2011-02-25 05:04:18   Reply...
From: Avishai
Does KGrid support BiDiMode? If not, are there plans to add this?
inserted: 2011-02-25 08:54:28   Reply...
From: tk
Yes but when I have time there are other priorities that I'd like to add (tree columns, extended sorting etc.)
inserted: 2011-02-17 09:18:41   Reply...
From: Automatic refresh
Hey tk. Here's another question, that I didn't find solution. I override OnDrawCell event of TKGrid and inside I have a code like this: var Col_ : TColor; HA : TKHAlign; VA : TKVAlign; HP, VP, ND : Integer; begin if ARow = 0 then begin HA:=halCenter; VA:=valCenter; HP:=0; VP:=0; Col_:=clYellow; end ... if ACol = 0 then KC.CellPainter.Canvas.Font.Color:=clBlack else KC.CellPainter.Canvas.Font.Color:=clWhite; ... KC.CellPainter.DefaultDraw; DrawAlignedText(KC.CellPainter.Canvas, R, HA, VA, HP, VP, KC.Cells[ACol, ARow], Col_, []); However changing the color does not occur until either mouse is moved over a cell or grid is scrolled. I thought after painting it should change color. I know you've been busy lately but I need this, so that's why I bother you. Can you please help me? Regards, Javor
inserted: 2011-02-17 13:47:55   Reply...
From: tk
Oh thats terrible to read I should allow a code formatting to these comments.. But back to the issue> Your approach is incorrect. Either you use DefaultDraw or you use another painting routines. Please don't combine these. I don't see entire code but please comment out the DrawAlignedText and assign KC.Cells[x,y] to KC.CellPainter.Text before you call DefaultDraw. Then the color must be changed each time the cell is painted.
inserted: 2011-02-16 00:04:20   Reply...
From: Raymond
Is there a way to have multi-column sorting? I would like to sort by multiple columns... Sort on [Customer Status] and then [Customer Name]. Can this be done?
inserted: 2011-02-16 18:22:16   Reply...
From: tk
I'm sorry but multi-level sorting is not supported.
inserted: 2011-02-15 09:30:19   Reply...
From: Javor
Hey tk. Glad to see you're keeping up the good work! Now to the problem: long ago (in earlier versions of the KGrid control) I've posted a problem where if you make a KGrid descendant at design time and set FixedCols to 0 at design time and reopen the form an exception was raised: "Error creating form: Error reading KGrid1.ColWidths: Invalid property value". This was fixed, but the problem persists on TKDBGrid control. I'm using Delphi 2010 and checked this over 100 times - every form that I have a TKDBGrid throws an exception after reopening it with FixedCols set to 0. Any fast solution? Lol, can't compile my project and don't want to edit your code in order to have future compatibility with new versions. Thanks in advance. Regards, Javor
inserted: 2011-02-16 18:21:02   Reply...
From: tk
I'm sorry I don't have time to test that. If you find a bug pls. send to tk@tkweb.eu
inserted: 2011-02-01 14:20:20   Reply...
From: Finn
Got other questuion. Is there any command which can assaign currently edited row to DB in KDbGrids? Now i notice that i have to click elsewhere, other row if i want to post currently edited row. But what happen if i have only one row, and no other row to click? How i can post it from code? You said you aint devellopping KDBgrid but mayby you know if it spossible to post somehow. Sorry for bothering
inserted: 2011-02-01 18:34:40   Reply...
From: tk
Did you try KDBgrid.Commit from code? Anyway I have almost no time to develop even KGrid:-( And this status I expect for another 5 months...
inserted: 2011-02-02 09:47:53   Reply...
From: Finn
i work it around somhow with few lines and KDBGrid.BeforeCellUpdate(0,0); in form destroy event.
Older comments
My account
Top downloads
Recently modified

KControls Development Suite

by: tk

2012-04-03

KHexEditor

by: tk

2010-11-08

KGrid

by: tk

2010-11-08

KIcon

by: tk

2009-11-24

KGrid 1.3 released.

by: tk

2009-08-10

Recently inserted

Update for RAD Studio XE2

by: tk

2012-04-03

KComponents as open source

by: tk

2011-04-16

Problem with comments and logins

by: tk

2010-01-29

KControls released

by: tk

2009-10-15

Working hard on KGrid update...

by: tk

2009-06-22

EMWD

by: tk

2007-12-03