Delphi and Lazarus
Trekking and Events
Blog and Forum
Čeština English
Main menu
Delphi and Lazarus
Top downloads
KGrid (23598x)
KControls Component Suite (15176x)
KHexEditor (5278x)
KIcon (2584x)
CAN Event Manager (401x)

KControls Component Suite

KControls is a freeware distribution, a flagship of tkweb. It contains all of my published components for Delphi and Lazarus. All controls have been written with the aim to become both cross-IDE compatible (Delphi/C++Builder VCL and Lazarus LCL) and cross-platform compatible in Lazarus. There are some exceptions to this scheme, see below.

Components included
TKGrid - powerfull control for working with table data, replacement for TStringGrid and TDrawGrid - full compatibility and lot of new features
TKDBGrid - control for working with database tables, possible replacement for TDBGrid
TKMemo - native replacement for TMemo/TRichEdit - written from scratch, great features, full RTF support etc.
TKHexEditor - another useful control for binary file editing
TKIcon - powerfull component for working with icons and cursors (files *.ico and *.cur, works only on Windows)
TKPrintPreview - control for displaying print preview, it is part of KControls built in printing capabilities, every visual control supports printing and previewing
TKPrintPreviewDialog - nonvisual component - dialog - for an easy print preview implementation
TKPrintSetupDialog - nonvisual component - dialog - for an easy implementation of printing preferences
TKCustomControl - a base for your visual controls, for which you want to implement e.g. printing and previewing capabilities in Delphi or Lazarus (just 2 short functions to write).
TKNumberEdit - edit control to input numbers in various formats
TKFileNameEdit - edit control to input file names
TKLinkLabel - label to show clickable link
TKGradientLabel - label with gradient background
TKLog - component for event logging
TKPercentProgressBar - custom drawn progress bar which shows actual percentage of the progress
TKBrowseFolderDialog - wrapper for the standard Windows API browse for folder dialog (works only on Windows)
TKBitBtn - like TBitBtn - draws PNG and alpha channel correctly in Delphi, has WordWrap property, works in Lazarus as well
TKColorButton - just another button to pick color
TKPageControl - page control written from scratch with custom painted tab panel, has tab icons and close button icon


KControls is provided free on 'as is' basis, with complete source code. However, it is licensed software. More information about license can be found in source file headers.

All controls support Delphi and Lazarus IDEs fully. But there are some exceptions: TKIcon and TKBrowseFolderDialog work only on Windows and printing and previewing might not work in some widgetsets in Lazarus.

Note about cross-platform development in Delphi: I strongly disagree with the way Embarcadero took with the FMX library to allow cross-platform development, so FMX will never be supported. As Lazarus has become very good IDE, in many aspects better than Delphi, I recommend you try it if you need cross platform features.


If you want to donate for further development of KControls just think about building your own photovoltaics and using the WATTrouter device produced by our company. You will save lots of energy and it will be the best donation to me you can make!

Screenshots (click the images to enlarge)

KControls components (Windows Vista)KControls components (Windows XP/GTK2runtine)
KMemo rich text editor showing the KMemo manual.KMemo rich text editor showing more complex sample RTF document.

Repository - development versions

You may now download newest development version at bitbucket. But be careful! These versions are mainly tested in Delphi XE where our main development is still ongoing!

Downloading KControls

Important note: When installing the packages in Delphi XE2 and later you must add "Vcl;Vcl.Imaging" to Unit Scope Names in Delphi Options/Library! Otherwise the packages won't compile!

FileVersionNumber of
Available for:Changes
kcontrols_1.7.zip1.72886Delphi 7+,Lazarus 1.2.2+, C++Builder 2007+support for RAD Studio XE8, major work on TKMemo which is already usable, bugfixes...
kcontrols_1.6.zip1.62534Delphi 6+,Lazarus 1.2.2+, C++Builder 2007+support for RAD Studio XE6, Columns property in TKDBGrid, bugfixes...
kcontrols_1.5.zip1.5319Delphi 6+,Lazarus 1.2.2+, C++Builder 2007+new components TKMemo, TKBitBtn, TKColorButton, some bugfixes...
kcontrols_1.4.zip1.4960Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+support for RAD Studio XE3-XE5, new components etc.
kcontrols_1.3.zip1.32691Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+support for RAD Studio XE2
kcontrols_1.2.zip1.23055Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+cumulative update (KGrid 1.7, KHexEditor 1.5, KIcon 2.2)
kcontrols_1.1.zip1.11069Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+cumulative update (KGrid 1.6, KHexEditor 1.4, KIcon 2.1)
kcontrols_1.0.zip1.01662Delphi 6+,Lazarus 0.9.29(SVN#21827)+initial release (KGrid 1.5, KHexEditor 1.4, KIcon 1.9)

If you have a question you may ask below and I will probably answer it, after some time.


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

Search in comments: 
inserted: 2016-05-31 01:47:50   Reply...
From: RobV
hi tk,
how could copy a preview page to bitmap?

(I tried but half of the page appears in black)

inserted: 2016-05-31 09:42:04   Reply...
From: tk
I don't know, never been using this. The print preview has not been designed that way, but iirc the components themselves have the PaintToCanvas method which could be used with any canvas.
inserted: 2016-05-31 11:15:23   Reply...
From: tk
Maybe TKPrintPreviewForm.preview.PaintTo used with Bitmap.Canvas.Handle would work. Never tested this however. Lazarus has an overloaded PaintTo that can be used with Bitmap.Canvas directly.
inserted: 2016-05-31 23:11:56   Reply...
From: RobV
his suggestion did not work.
Under a situation that works with memo.blocks.paintToCanvas

procedure TKMemoFrame.SpeedButton3Click(Sender: TObject);
var bm:TBitMap;
  editor.canvas.Refresh ;
  SaveIndex := SaveDC(editor.canvas.Handle);
  bm.Width:= editor.Width ;
  bm.Height:= editor.Height+1500 ; //i.e. 1500 or more
  r:=rect(0,0,bm.Width ,bm.Height );
  Bm.Canvas.Brush.Color := clWhite;
  editor.Blocks.PaintToCanvas(bm.canvas,0,0,r) ;
  RestoreDC(editor.canvas.Handle, SaveIndex);
  editor.canvas.Refresh ;

inserted: 2016-05-26 04:09:19   Reply...
From: Бегемот
Nice try but it won't work with RX10 Seattle.
inserted: 2016-05-26 20:33:37   Reply...
From: tk
The repo download should work already, although I didn't test this myself.
inserted: 2016-05-27 03:57:45   Reply...
From: Бегемот
Nope. The package installs with no components. Maybe Win10 is the cause...
inserted: 2016-05-27 10:32:47   Reply...
From: tk
Hmm, was contribution from another user. Maybe the package for D10 is corrupted. The ever soaring prices for Delphi are the cause that I haven't tested this myself yet. I/we won't buy Delphi anymore, will entirely migrate to Lazarus. But I'll at least download the evaluation and try this package myself.
inserted: 2016-05-27 10:56:49   Reply...
From: tk
Will test only the new Berlin release.
inserted: 2016-05-27 12:29:01   Reply...
From: tk
Tested now on 10.1 and modified also the Seattle packages a little. The run time package was corrupted, missing the KDBGrids.pas file. For some reason I had to add path to sources to the design time package dproj files, don't know why Delphi suddenly did not find the res files etc. when compiling design time package. Things that worked fine all the time don't work anymore:-( Seems that the new Delphi versions are not only more and more expensive, but even worse and worse.

I still have W7 but the programs we create with KControls run on W10 normally.
inserted: 2016-05-23 16:06:38   Reply...
From: RobV
Hi Tk,

I believe you will like to see these settings in the preview of kmemo (only).
I Fix so that the texts were not being displayed properly when the page
changes, both in preview and in printOutput. Modifications incorporated,
sought comment with "//Adicionei"

I posted the link below for you to download (I will leave a few days)

I could not make all text displayed in the preview,
is exactly the same position when printed (eg pdf creator,
Microsoft print to pdf or HP printers).
This is for you to know quite the windows api.

The result is that the kmemo is approaching an
WYSIWYG editor

The next step is to place a ruler in this editor
inserted: 2016-05-24 09:15:12   Reply...
From: tk
Thank you but could you modify the newest repository snapshot and send me the patch? This way I am unable to apply your contributions to the main trunk.
inserted: 2016-05-24 15:53:48   Reply...
From: RobV
I do not know the latest repository. What is it?
inserted: 2016-05-25 10:59:15   Reply...
From: tk
See above, the link to BitBucket. Please go there and download current repo snapshot. Implement your modifications there. I/We must review each contribution thoroughfully to avoid some problems in our projects.

After a short review of your modifications I have following notes:

Please avoid old fashioned constructs like:

  PLinkNP = ^AListNP; //Adicionei*
  AListNP = record //Adicionei*
    I:integer; // = line
    Value:integer;// = page

  PLinkTop = ^AListTop; //Adicionei*
  AListTop = record //Adicionei*

Instead of these use classes and object lists (because of compatibility with old Delphi versions use normal object lists with custom getters and setters, see the many helper classes in kmemo.pas for reference).

Also please ALWAYS avoid using global variables!

  linkPagePrev: Integer;//Adicionei*

This way the {$WEAKPACKAGEUNIT ON} directive would not work in Delphi! Rather than that use some helper classes for this and instantiate them directly in TKCustomMemo class (or whenever you use it)!

Also please avoid commented out code chunks when possible.

Thank you
inserted: 2016-05-25 17:22:30   Reply...
From: RobV
I did so (temporary) because they do not know with certainty the structure of objects in kcontrol. The primary objective was to test what was inconsistent. (I'm new here ok?) Anyway I appreciate your guidance and few know its structure, will have conditions
to incorporate in existing objects.

tk: what is the reason of a plain text is displayed in a position (preview canvas), different from what is printed (printer canvas)? Where (procedure / functions) you suggest I can step up testing to try to hunt this inconsistency?

inserted: 2016-05-26 20:03:22   Reply...
From: RobV
tk: in the lazarus (because I am avoiding using the Delphi)
I tested considering {.$DEFINE KMEMO_DISABLE_KERNING} whether the texts are now displayed in the screen canvas as the printer canvas that is ok!

you'd better clarify the reason for this occurrence since the file the question is about speed and not text display position.
inserted: 2016-05-26 20:31:26   Reply...
From: tk
I remember having problems with kerning pairs when testing under Linux Kubuntu. That's the reason for this directive, the problem was IMO not in Lazarus but in underlying GTK engine.
inserted: 2016-05-21 00:15:36   Reply...
From: iru
Could you please explain the relationship between CELL, CELLS and COLUMN/S?
I am having troubles with "column" display widths when I use "KDBGrid.Cells[0, ?] := 'xxx'. How can I control the "CELL, ""COLUMN"width?
inserted: 2016-05-21 02:06:52   Reply...
From: iru
On a closer look the problem is not the width of the displayed columns but that some columns overlap others. For example, if I have a grid with 10 columns and perform the following:
  For i := 2 to 5 do
    KDBGridLap.Cells[i, 0] := 'Lap ' + IntToStr(i);

The display is: Col0|Col1|L|L|L|Lap 5|Col6...... (where Col0/1/6 are "normal" columns).
inserted: 2016-05-22 14:22:46   Reply...
From: tk
Don't understand what you're up to. You're assigning values to Cells in a DBGrid? But that's IMO generally wrong unless I miss sth. In KDBGrid cells are automatically filled with data from the data set and your values get overriden on next data update event!

To adjust column widths use ColWidths property or the Columns[x].Extent property at design time. At runtime Cols[x] is quite equal to Columns[x] (Cols is just shorter variant for Columns).
inserted: 2016-05-24 12:37:03   Reply...
From: iru
Apologies about KDBGrid, should have been KGrid.

I have been looking at KGrid source and pottering with my code.
Issuing KGridLap.Cols[vCtr].MinExtent := InSize (where InZize is 55,just longer than the size of something like 'Lap 12.0') seems to resolve things.

Thank you for your response, Ian
inserted: 2016-05-29 12:57:53   Reply...
From: iru
Some more this. Setting KGridLap.Cols[vCtr].MinExtent solved the problem once.

Run some code, the column widths are OK, columns are visible.
Run the same code again and the columns are in-visible.
Run the same code again and the columns are OK, columns are visible.

I have put traces in the KGrid code and have been able to work out where things start to go wrong.

I have inserted some ugly code at the start of Kgrid.SetVisible as follows:
    FBackExtent := 0;
    Extent := 64;

Ugly but it fixes the display.

I think it will take me some time to sort this out.With your experience with KGrid it may be simple.

The application is small and self contained. Is there some way I can send it and usage instructions?

Thanks, Ian.

inserted: 2016-05-31 09:30:46   Reply...
From: tk
Thank you for the example but it cannot be loaded. Lazarus reports: Unable to find the component class "TLEDNumber"... It is needed by unit:...frmmain.pas.
inserted: 2016-05-31 09:45:18   Reply...
From: tk
Was the missing industrial package (my Laz strangely reported the missing package only when compiling, not when loading the project).

But there are another errors when compiling:
Compile Project, Target: LS.exe: Exit code 1, Errors: 8, Hints: 1
frmmain.pas(158,3) Note: Local variable "vTime" not used
frmmain.pas(266,12) Error: Identifier not found "vSList"
frmmain.pas(285,12) Error: Identifier not found "vSList"
frmmain.pas(307,22) Error: Identifier not found "vSList"
frmmain.pas(341,27) Error: Identifier not found "vSList"
frmmain.pas(342,27) Error: Identifier not found "vSList"
frmmain.pas(393,4) Error: Identifier not found "DataModuleDB"
frmmain.pas(393,36) Error: Identifier not found "DebugIni"
frmmain.pas(393,61) Error: Identifier not found "DebugIni"
inserted: 2016-05-31 10:09:58   Reply...
From: tk
Ok, run it on Win, had to add the vSList to kgrids.pas and comment out the line:
DataModuleDB.DM.AppName := Copy(DebugIni, 1, Pos('.INI', DebugIni)-1);

Then I could find the problem.


Procedure UpdateVis(InCol : Integer; InNumber : Integer; InState : Boolean);
    vCtr :Integer;
    For vCtr := InCol to (InCol + InNumber - 1) do
      if InState then
        KGridLap.ColWidths[vCtr] := KGridLap.DefaultColWidth
        KGridLap.ColWidths[vCtr] := 0;

Don't use Cols[x].Visible because it is known to be somewhat buggy. Also you should use ColCount instead of this to specify column count. This will avoid hidden columns.
inserted: 2016-05-30 22:33:22   Reply...
From: tk
Well, I still don't understand what is the problem. I don't use MinExtent properties so there might be bug. Please create a simple app that demonstrates the problem and send it to the email provided in source headers.
Thank you
inserted: 2016-05-31 23:56:21   Reply...
From: iru
Thank you for your response and your work. Apologies for the missing components/errors in the code. Must be strange things in my LAZ IDE.

All fixed, problem solved.
Thanks once again, Ian
inserted: 2016-05-14 03:10:52   Reply...
From: RobV
Hi tk,
to add single image from clipboard

function TKMemoBlocks.AddImageBlockFromClipBoard(At: Integer): TKMemoImageBlock;
var pic : TPicture;
     Jpg : TJPEGImage;


  if (Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap))) or

  (Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap))) then begin

    Result := TKMemoImageBlock.Create;

    pic:=TPicture.create ;

    if Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap)) then



    if Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap)) then


     Jpg := TJpegImage.Create;
       Jpg.Assign(pic.Graphic );

       AddAt(Result, At);



inserted: 2016-05-15 05:42:43   Reply...
From: RobV
small adjustment to copy the contents of clipboard to exact location of the cursor positioned

function TKMemoBlocks.AddImageBlockFromClipBoard: TKMemoImageBlock;
var pic : TPicture;
     Jpg : TJPEGImage;


  if (Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap))) or

  (Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap))) then begin

    Result := TKMemoImageBlock.Create;

    pic:=TPicture.create ;

    if Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap)) then



    if Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap)) then


     i:= Count ;

     Jpg := TJpegImage.Create;
       Jpg.Assign(pic.Graphic );

       AddAt(Result, i);




procedure TForm1.SpeedButton1Click(Sender: TObject);
  Stream: TMemoryStream;
  S: TKString;
  IB: TKMemoImageBlock;

    IB := KMemo1.Blocks.AddImageBlockFromClipBoard;
    if ib=nil then ib.Free
    else begin

     i:=kmemo1.blocks.Count-1 ;
     kmemo1.Blocks.Items[i].SelectAll ;

      S := kmemo1.ActiveBlocks.SelText;
      Stream := TMemoryStream.Create;
        kmemo1.SaveToRTFStream(Stream, True);
        Stream.Seek(0, soFromBeginning);
        kmemo1.LoadFromRTFStream(Stream, kmemo1.RealSelEnd );

      kmemo1.ActiveBlocks.ClearSelection(false) ;



inserted: 2016-05-22 14:10:04   Reply...
From: tk
Thank you.
inserted: 2016-05-13 15:29:51   Reply...
From: Woj
When I use kPrint in preview I see only records which are visible on the screen, other records are empty.
But when I scroll down in kdbgrid these records appear. Earlier I used dbgrid.datasource.dataset.last function to bypass problem, but now I have more records (abaout 500) and this trick doesn't work. Could you tell me what can I do to solve this problem?
inserted: 2016-05-14 13:51:04   Reply...
From: tk
The preview shows only currently loaded rows/records from the dataset. It does not load new records like when scrolling the grid. If you want to show all records in the preview then you must somehow load them into the grid. You can try new method LoadAllRecords that simplifies that task for KDBGrid, see the repo.
inserted: 2016-05-15 21:49:37   Reply...
From: Woj
It's what I've been looking for, thank you very much.
inserted: 2016-05-04 14:28:59   Reply...
From: HexUser
Is it possible to group only 2 Hexchars in the KHexEditor, for viewing full Bytes (8 Bit)?
inserted: 2016-05-09 10:58:33   Reply...
From: tk
Yes, use DigitGrouping property.
inserted: 2016-05-09 15:01:27   Reply...
From: HexUser
inserted: 2016-05-04 12:07:44   Reply...
From: Whisper
I've got a problem with Kgrid.
I'm doing an application and If I add the following code to the event "DrawCell" (Resultados is the kgrid type).

the code is for formatting the cells
procedure TBuscaDu.ResultadosDrawCell(Sender: TObject; ACol, ARow: Integer;
  R: TRect; State: TKGridDrawState);
   Resultados.CellPainter.Text := Resultados.Cells[ACol, ARow];
   if (ARow > 1) and (ACol >= 3) then Resultados.CellPainter.HAlign := halRight;
   if (ARow = 0) and ((ACol = 3) or (ACol = 4)) then Resultados.CellPainter.HAlign := halCenter;
   if (ARow = 0) and (ACol >= 1) then
         Resultados.Font.Size := Resultados.Font.Size+10;
         Resultados.Font.Bold := TRUE;
   if (ARow = 0) and (ACol >= 1) then
         Resultados.Font.Size := Resultados.Font.Size-10;
         Resultados.Font.Bold := FALSE;

Kgrid blocks the red button to finish the aplication. I can NOT close/terminated the aplication

Is it a bug?

PD: I've uploaded a simple test project where you can see the problem. If you press the NEW button, Kgrid show up and now if you push the closed/finish red button, it doesn't work properly.!3QMm1Jha!PpUKtWYSG_-wTj68NftlpoUtSyv3HSouwOCYM9CQj8w
inserted: 2016-05-06 12:37:38   Reply...
From: Whisper
Fixed the issue:

if I change:

Resultados.Font.Size -> Resultados.CellPainter.Canvas.Font.Size

The same for the rest of code
inserted: 2016-05-16 09:55:16   Reply...
From: tk
You should only access Resultados.CellPainter.Canvas.Font in OnDrawCell, not Resultados.Font.
inserted: 2016-05-02 13:57:24   Reply...
From: CrazyDron
Good day!
I have installed v1.7 of KControls and using Win7 x64.

After creating new project and adding onto form control TKGrid - it compiles normal.

But when I set options of project to:
1. Target OS: WinCE
2. Target CPU: arm

compilation stops at unit CairoCanvas and says
cairocanvas.pas Fatal: Cannot find unit Cairo, used in CairoCanvas of package cairocanvas_pkg.

(Remark: units Pango, PangoCairo, GLib2 are not founded too).
What should I do?
Thank you.
inserted: 2016-05-02 21:04:30   Reply...
From: tk
I think your Lazarus installation or build configuration is corrupt under Linux or not ready for cross compiling. I am not expert here. Please search or ask on Lazarus forum There are many clever people that might be able to help you.
inserted: 2016-05-03 08:05:17   Reply...
From: CrazyDron
Thank you, and my apologizes about not refining that I write in Lazarus.

My Lazarus installation is Win32+cross_arm_ce.
I write big project for WinCE/arm, and it compiles and works perfectly. But all this is on standard installation, external components is only KControls.

Maybe this information help you (and me too :D ).

inserted: 2016-05-03 12:16:45   Reply...
From: tk
Well, I don't have this installation so I am not able to help you. Generally I've always tested only on Win or Linux, x86 or x64. I don't even know if KControls works in other widget sets.

Please ask on Lazarus forum about this error.

inserted: 2016-05-01 16:13:28   Reply...
From: Whisper
I have a problem with Kgrid and CheckBox.

I add checkboxes to col 0 (the first of the left side) in kgrid with the code:

procedure TBuscaDu.ResultadosDrawCell(Sender: TObject; ACol, ARow: Integer; R: TRect; State: TKGridDrawState);
   if (ACol = 0) and (ARow > 0) then
        Resultados.CellPainter.CheckBox := TRUE;
        Resultados.CellPainter.CheckBoxHAlign := halCenter;
        Resultados.CellPainter.CheckBoxState:= cbchecked;
(Resultados is the kgrid type)

but I don't know how i can change the state from the cbchecked to cbUnchecked from one of the checkboxes with click of mouse (I make a click, but it doesn't change) and how I can detect if the user change the checked state.

Thanks in advanced
inserted: 2016-05-02 21:00:34   Reply...
From: tk
You have to instantiate a TCheckBox as inplace editor. Look in the demo how to do that.
inserted: 2016-04-28 22:53:56   Reply...
From: RobV
I tested now and that may be a temporary solution would prevent any table comes in first line, always enter a container block like this:

  TBL: TKMemoTable;
  CO: TKMemoContainer;
  CO := KMemo1.Blocks.AddContainer;
  CO.Position := mbpRelative; //important
  CO.RequiredWidth := 3;

  TBL := KMemo1.Blocks.AddTable;
  TBL.ColCount := 2;
  TBL.RowCount := 2;
  TBL.Cells[0, 0].Blocks.AddTextBlock('Table text 1');
  TBL.Cells[0, 1].Blocks.AddTextBlock('Table text 2');
  TBL.Cells[1, 0].Blocks.AddTextBlock('Table text 3');
  TBL.Cells[1, 1].Blocks.AddTextBlock('Table text 4');
  TBL.CellStyle.BorderWidth := 1;

after 15 years I am migrating from Delphi to Lazarus and user from TRichView am evaluating your (good component) for probable replacement. Do you consider the stable and consider if you or someone already use for at least 03 years?

grateful for the attention

inserted: 2016-04-29 12:01:19   Reply...
From: tk
Don't fully understand the question but KMemo should be already reasonably stable. Of course there are still important features missing as the readme states. These will be gradually implemented when I or one of the contributors have time. Now highest priority is Undo/Redo and image editing tools.
inserted: 2016-04-28 21:53:14   Reply...
From: RobV
let's see if I understand you:
once the table is created, even the way you suggested, put a block before, after this if the user navigates to the first line of kmemo1, and repeatedly typing Delete the table created will position the first line of kmemo1. OK ? So far of course, but what is not correct is that after that I can not move again this table again for any line below! Exactly this is the point. What to do or stop so that this does not happen?
Otherwise you could tell a simple example of your solution?

----->first line (create with i.e. TB := KMemo1.Blocks.AddTextBlock('Hello world!')
 _____ _____ -----> second line with table
! !
! !

after these in first line the user press some key delete:

 _____ _____ -----> first line (of memo) with table
!x !
! !
after this kmemo does not allow the user move this table (this is the point)

how to write a fix for this?

inserted: 2016-04-28 22:35:36   Reply...
From: tk
AFAIK this is same for all word processors. I remember having these problems with Word recently, in one of my documents. Had to cut the table to clipboard, enter paragraph and insert it again. Maybe newer Word solves this, been using Word 2007.

Anyway, this would need some specific fix in KMemo.
inserted: 2016-04-28 13:23:52   Reply...
From: RobV
follow these steps:
1.create a simple table in the first row of kmemo1.(Make sure the cursor is in the first cell, that is exactly the first position of the memo1)
2. you can move the entire table with the keyboard or mouse to the 10th line (or any other line) of kmemo1? how?

inserted: 2016-04-28 13:40:32   Reply...
From: Tk
Aha. Is the same as your point 2. You need to add some other block before the table. Then you can move caret to this block and move table lower with enter key.
inserted: 2016-04-27 19:21:10   Reply...
From: RobV
correction in (1) is to move the table down the first line
inserted: 2016-04-27 19:01:01   Reply...
From: RobV

in lazarus, last version, i create table in first line
procedure TForm1.SpeedButton1Click(Sender: TObject);
  TBL: TKMemoTable;
  TBL := KMemo1.Blocks.AddTable(0) ;
  TBL.ColCount := 2;
  TBL.RowCount := 2;
  tbl..FixedWidth:=false ;
  TBL.Cells[0, 0].Blocks.AddTextBlock('Table text 1');
  TBL.Cells[0, 1].Blocks.AddTextBlock('Table text 2');
  TBL.Cells[1, 0].Blocks.AddTextBlock('Table text 3');
  TBL.Cells[1, 1].Blocks.AddTextBlock('Table text 4');
  TBL.CellStyle.BorderWidth := 1;
(1) after that I can not move the table down to the first line.
(2) also can not move the cursor after the last cell in a way that goes beyond the table.

How do you suggest?
inserted: 2016-04-27 22:35:31   Reply...
From: tk
1) I don't understand this.
2) You have to add at least one other block (e.g. a paragraph block) after the table.
inserted: 2016-04-26 12:36:19   Reply...
From: Whisper
I would like align the text in two diferent ways: left and right in the same columm in KGRID.

I looked for code in the examples, but I don't get to work properly. Could you give a short example for this issue?

Thanks a lot
inserted: 2016-04-27 22:37:50   Reply...
From: tk
If you mean text justification (both left and right alignment) then neither KMemo nor KGrid's CellPainter support this yet. You would have to choose some external routine and draw the text in KGrid's OnDrawCell.
inserted: 2016-04-28 12:25:04   Reply...
From: Whisper
Thank you for your answer.

In lazarus forums one person said to me there is a HAlign property for that. Is it wrong?

Can not I align the text in the first row of the one col to the left, and the next rows, of this col, to the right?
inserted: 2016-04-28 14:05:11   Reply...
From: Tk
Now I understand. Yes you can use Halign property. You can align text in every cell differently.
inserted: 2016-04-28 16:47:27   Reply...
From: Whisper
But I don't know how I should do. Could you write a small example?
inserted: 2016-04-28 21:47:48   Reply...
From: tk
This should draw each odd row with different alignment than even row. Didn't test, written now from scratch:

procedure TForm1.KGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; R: TRect; State: TKGridDrawState);
  KGrid1.CellPainter.Text := KGrid1.Cells[ACol, ARow];
  if ARow mod 2 = 0 then
    KGrid1.CellPainter.HAlign := halLeft
    KGrid1.CellPainter.HAlign := halRight;
inserted: 2016-04-29 11:50:53   Reply...
From: Whisper
Thanks a lot.

I studied your example code, I realized that I forget this line:

 Resultados.CellPainter.Text := Resultados.Cells[ACol, ARow];
(Resultados is Kgrid type)

I "lost" the text. Now, This code fixed the issue.

Thank very much

inserted: 2016-04-30 18:41:04   Reply...
From: tk
Or you could use different cell class, eg. TKGridAttrTextCell. There you can define text alignment and other features for each cell directly, without having to call OnDrawCell.

Cell classes are very powerful feature for non-virtual (typically smaller) grids, allowing you to code grid events once and use these then for many grids with just a simple assignment. Unfortunately this feature is not well documented and neither well shown in the demos.
inserted: 2016-04-24 03:04:47   Reply...
From: seci20
hex edit find and replace command help me ?
inserted: 2016-04-27 22:39:03   Reply...
From: tk
AFAIK there are such commands available, can be used in the hexeditor demo.
inserted: 2016-04-23 12:51:46   Reply...
From: jaume
Can KGrid wordwrap cells, show memo text and graphics?
inserted: 2016-04-27 22:41:06   Reply...
From: tk
It should be readily possible via the KGrid.CellPainter. Some of these features are shown in the KGrid demo, some you have to figure out yourself.
inserted: 2016-04-03 19:29:55   Reply...
what change fontname , size and color in the cells?
thank you
inserted: 2016-04-04 09:35:47   Reply...
From: tk
Everything in OnDrawCell, see the demos.
inserted: 2016-03-28 12:41:43   Reply...
From: wot
How do I set title and fieldname in kdbgrid like in dbgrid?
In Dbgrid I can use something like this:
and it works. In kdbgrid there is no fields "fieldname" and "title".
Is there any solution for dynamically do that?
inserted: 2016-04-02 20:53:55   Reply...
From: tk
As the Columns property is inherited from ancestor TKGrid class (this is the difference between TDBGrid and TKDBGrid) you must use typecast or the AS keyword here:
TKDBGridCol(DBGrid.Columns.Items[0]).FieldName := 'Id';
(DBGrid.Columns.Items[0] as TKDBGridCol).FieldName := 'Id';
inserted: 2016-03-02 10:17:15   Reply...
From: josefkoller

I use KMemo and it looks fine.
But I have one problem in preview.

For example:

I type only a sort phrase in Kmemo like: "short test". (fontname is "Consoloas", fontsoze is 9).
After clicking preview I see this short phrase, but it's to big and the phrase look's like centered.

Only I have a longer phrase in the text (width like component-with) I see the phrases in preview in correct fontsize and fontname.

What's wrong in my behavior?



Lazarus 1.6,FPC:3.0.0, win32
Kcontrols 1.7

inserted: 2016-03-08 09:47:37   Reply...
From: tk
This is normal in current state as paging has not yet been implemented.
KMemo has only basic print/preview caps now. Partial workaround is to uncheck Fit to page option in the print settings but this can cut the text on right side for bigger documents.
inserted: 2016-02-01 05:49:30   Reply...
From: heri
how setting cell word wrap
inserted: 2016-01-31 18:05:30   Reply...
From: johnvantelli

I set ColCount = 3
and in my formCreate set col 2 not visible

but scrolling cells program freeze!!
Any ideas??


procedure TForm1.FormCreate(Sender: TObject);
inserted: 2016-02-01 11:48:27   Reply...
From: tk
Cols[x].Visible is buggy. Use ColWidths[2] := 0; as workaround.
Same for Rows.
inserted: 2016-02-01 20:35:57   Reply...
From: johnvantelli
same problem...

I set:

FixedRows := 0;
FixedCols := 0;
ColCount := 3;

ColWidths[0] := 200;
ColWidths[1] := 0;
ColWidths[2] := 0;

but moving cell cursor on right program freeze
I think the problem is that component try to set focus on an invisible cell.
inserted: 2016-02-03 16:17:25   Reply...
From: tk
I can confirm there is some bug causing KGrid to freeze, even in Delphi. Some recent update introduced this blocker. Please, give here the Lazarus version and what demo causes the crash.
inserted: 2016-02-08 19:34:07   Reply...
From: tk
This bug was not in KGrid but in another place of our application.
inserted: 2016-02-03 13:46:42   Reply...
From: tk
Is it fresh installed Lazarus and some short demo project?
inserted: 2016-02-03 21:35:41   Reply...
From: johnvantelli
Lazarus fresh installed...

Version 1.4.4
rev.SVN 49931

To test the crash I create a new project, put KGrid in main form and in formCreate insert this code;

KGrid1.FixedRows := 0;
KGrid1.FixedCols := 0;
KGrid1.ColCount := 3;

KGrid1.ColWidths[0] := 200;
KGrid1.ColWidths[1] := 0;
KGrid1.ColWidths[2] := 0;

inserted: 2016-02-08 19:55:28   Reply...
From: tk
I could reproduce now, needed more moves with keyboard. The issue should be fixed, download the repo.
inserted: 2016-02-08 19:38:39   Reply...
From: tk
Cannot reproduce the bug with the same code and same fresh Lazarus on Win7x64, with all project options set to default.
inserted: 2016-01-29 05:47:33   Reply...
From: bpranoto
Hello, is it possible to:

1. Create merged header on TKDBGrid? How to do that?
2. Create column footer?

Thank you.
inserted: 2016-01-30 19:17:57   Reply...
From: tk
1. Should be possible via CellSpan but I never tested with KDBGrid.
2. Column footer (for sums etc.) is not implemented yet.
inserted: 2016-01-31 11:03:29   Reply...
From: bpranoto
Thanks, I also notice TKDBGridCol does not have title alignment property. How do we create a center aligned column title?
inserted: 2016-02-01 11:39:39   Reply...
From: tk
Each drawing customization must be done in OnDrawCell.
Here you must set Grid.CellPainter.Attributes = halCenter. See the kgrid demo how to use CellPainter.
inserted: 2016-01-26 10:15:38   Reply...
From: JanR
I have been trying out your tkpagecontrol in Lazarus, but i cannot find any way to add tabs to this control in design time. Can you tell me where I do this?
inserted: 2016-01-30 19:15:38   Reply...
From: tk
Did you try some recent download from bitbucket? There it should be already possible.
inserted: 2016-01-25 17:45:43   Reply...
From: rdevine
Hi Tomas - I've been taking a look at your very nice grid. I currently use one from TMS and for virtual mode there is an OnGetCellData event I use. I looked at the virtual grid demo for TKGrid but can't see anything similar. The demo seems to just set fixed values in the form create - am I missing something?

BTW, I had to add the "Vcl." prefix in many of the units to get it to compile in XE7.

Thanks, Bob
inserted: 2016-01-30 19:14:28   Reply...
From: tk
KGrid has different approach for virtual mode. See the kgriddemo, 3rd page. There it is shown. Btw. read the installation notes, you do only need to modify the unit scope names in your Delphi (or project) settings.
inserted: 2016-02-01 22:55:07   Reply...
From: rdevine
Thanks - always a good idea to read the installation notes :-) I see the virtual mode now - some of my datasets have millions of rows and if I set the rowcount to even 100000 it struggles. The commercial grid I use has a type of paging where only required visible cells are created, so I can set millions of rows with no performance hit. Is a similar mode available for KGrid?

Thanks again.
inserted: 2016-02-03 13:59:27   Reply...
From: tk
No, the goVirtualGrid option in KGrid just prevents creating internal cell objects, but other algorithms (such as size calculations etc.) always iterate on all rows.
inserted: 2016-01-24 00:44:00   Reply...
From: Stefan
How to Save and Load KDBGrid's Columns Order ?
KDBGrid1.Columns.SaveToFile('DBGrid.txt') - it does not work
inserted: 2016-01-30 19:12:30   Reply...
From: tk
This is not possible with KDBgrid.
inserted: 2016-01-20 20:06:31   Reply...
From: tomsan

I am using Delphi 2010 on Windows 8. The package doesn't get compiled. Most of the problems are in kFunctions.
inserted: 2016-01-21 19:29:16   Reply...
From: tk
I was testing the 1.7 on D7, DXE and DXE8. No chance for me to test versions in between, but you can always pull the repo with TortoiseHg, fix the problems and send me a patch. I think if there are some problems, they will be with the compiler conditionals in
inserted: 2016-01-21 19:32:06   Reply...
From: tk
Actually meant their application in code, where I sometimes just guessed which Delphi version implemented what.
inserted: 2016-01-09 12:51:42   Reply...
From: gerard
FYI, I just downloaded the control set from bitbucket and installed it on Laz 1.6.0rc1 under linux X64.
There is an issue when installing under Linux: it complains that it doesn't find kdialogs.pas and kgrid.pas, and it's because of the files being there but with names partially in uppercase (KDialogs.pas & KGrid.pas)
Renaming the files to kdialogs.pas and kgrid.pas solves the problem.
Best regards,
inserted: 2016-01-10 16:28:42   Reply...
From: tk
I renamed the files on bitbucket, thank you.
inserted: 2015-12-30 20:06:03   Reply...
From: lechuDC
the problem missing function makecellspan i ver 1.7
inserted: 2015-12-30 22:44:40   Reply...
From: tk
MakeCellSpan has been moved to kfunctions.pas. This is because I needed the function in KMemo as well (because of KMemo tables).
inserted: 2015-12-31 02:00:48   Reply...
From: lechuDC
thanks; need to use kfunctions.pas with kgrid
Older comments
My account
Recently modified

KControls Component Suite

by: tk



by: tk



by: tk



by: tk


KGrid 1.3 released.

by: tk


Recently inserted


by: tk


Grouping of comments

by: tk



by: tk


My recent work on KMemo

by: tk


Update for RAD Studio XE2

by: tk