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

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. Please download and try this version if something is not working in the official release listed below.

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.75820Delphi 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.62663Delphi 6+,Lazarus 1.2.2+, C++Builder 2007+support for RAD Studio XE6, Columns property in TKDBGrid, bugfixes...
kcontrols_1.5.zip1.5357Delphi 6+,Lazarus 1.2.2+, C++Builder 2007+new components TKMemo, TKBitBtn, TKColorButton, some bugfixes...
kcontrols_1.4.zip1.41007Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+support for RAD Studio XE3-XE5, new components etc.
kcontrols_1.3.zip1.32722Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+support for RAD Studio XE2
kcontrols_1.2.zip1.23090Delphi 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.11096Delphi 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.01706Delphi 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: 2017-06-22 08:36:20   Reply...
From: см
I am executing the code below, trying to select a string occurring in a KMemo. It usually works, but it occurs that when the text is in a table containing merged cells things go wrong.
In the example below, I expect that „L4;C1‟ is selected, but instead the selected text is „L4;C2‟ which in located in the next column.
I have made compensation for the paragraphs (since it is two chars and they are considered as one). As far as I remember you mentioned that images are considered an extra char. Probably merged cells are also considered a char?
Could there be a way to select the found string?

The only idea I currently have is to count the number of paragraphs before the occurence, then find the position of the last paragraph before occurence of the text in the raw RTF and count images and merged cells within it (I could not find the text itself in the raw RTF, because it might be formatted).
But probably there is a more reliable and straightforward way?

procedure TForm1.cmdNestedTableClick(Sender: TObject);
   NestingTable: TKMemoTable;
   NestedTable: TKMemoTable;
   row, clm: integer;
   FoundPos, NLCount: integer;
   MergeSpan: TKCellSpan;
  KMemo1.Blocks.AddTextBlock ('');
  KMemo1.Blocks.AddTextBlock ('');

  for row:=0 to NestedTable.RowCount-1 do
    for clm:=0 to NestedTable.ColCount-1 do


    MyStream := TStringStream.Create('{\rtf1 Line1\par Line2\par Line3\par Line4\par');
    NestedTable.Cells[1, 1].Blocks.LoadFromRTFStream(MyStream);

  if FoundPos>0 then
      NLCount:=Occurs(LeftStr(KMemo1.Text,FoundPos),#13#10); //Counts the number of the new lince characters before the occurence of the string
inserted: 2017-06-22 20:47:46   Reply...
From: tk
Cannot compile the example:
Main.pas(678,16) Error: Identifier not found "Occurs".
inserted: 2017-06-10 00:51:00   Reply...
From: LookinGood
Hi, just found KMemo and it is looking good, but I need to be able to move the Caret to the bottom of a logging file when new stuff is being added.

I looked through the Source and could not find anything. How do I move the Caret to the very bottom of the file so the user can see new stuff being logged?

I played a little with ScrollBy but can't seem to make it work for me. I am using Lazarus in Ubuntu, so this may well be a "feature" of one or both though.
inserted: 2017-06-11 11:23:46   Reply...
From: см
I cannot check right now, but I am pretty sure you can find what you need in kmemo1.ExecuteCommand(ecGoto... ) or in something similar starting with "ec".
inserted: 2017-06-12 06:44:29   Reply...
From: см
This should do: KMemo1.ExecuteCommand(ecEditorBottom);
inserted: 2017-06-06 10:31:41   Reply...
From: см
Hi TK,
I have added some highlighting functionality to TKMemo (still for a single area only).
There is still some problem in the cases when selection and highlight overlap.
Anyway, could I upload the modified source somewhere so you could see it and consider using it in TKMemo (after the issue with overlapping is solved)?
Or should I use some tool to create a patch?
inserted: 2017-06-15 15:19:11   Reply...
From: tk
1. Before making any patches, be sure to test the modifications as described in kcontrols_readme.txt, see INFO FOR CONTRIBUTORS. Test at least in Lazarus trunk (1.7 or newer) and Delphi XE or newer (you can use some evaluation version).
2. To generate patch, use TortoiseHg Workbench (select changeset, then right click, select Export and click Export patch).
3. Send patch to my email.
inserted: 2017-06-02 12:09:57   Reply...
From: см
Hi TK,
TKMemo has several items in the .Color property.
I have tried them and it occurs to me that only .SelTextFocused and .SelBkGndFocused have influence.
BKGnd has influence in the IDE, but the colour is „forgotten‟ when the application is run.
Are the other .Color values implemented?

Also, there is a small bug occurring in Lazarus:
When some lines are manually selected and after that KMemo1.Select(9,5); is executed, then:
  1. Colour of the current selection changes (quickly)
  2. Current selection is removed.
  3. New selection is shown with the colours displayed in the end of step 1.
Imho, step 1 shall not happen at all.
inserted: 2017-06-03 14:58:11   Reply...
From: см
Suddenly some or all of the above values became applicable. Maybe the IDE did not understand that these changes were made or it did not recomplile. I have added some spaces in the code, before making the previous post (to make the IDE recompile) so maybe there is something odd.
inserted: 2017-06-03 11:05:44   Reply...
From: tk
About colors:
Colors.BkGnd is used only if Background.Color is clNone. Use Background.Color, Colors.BkGnd is deprecated.
All Colors.Sel* members are used.
No Colors.Inactive* member is used yet, they are reserved. They were copied from TKHexEditor and maybe will be implemented later.

About selection:
Very probably not a bug. You probably pressed a button to call KMemo1.Select and this button stole focus from KMemo. Which in turn caused the selection color change from Colors.SelBkGndFocused to Colors.SelBkGnd.
inserted: 2017-06-03 15:13:54   Reply...
From: см
Thanks for the info.
Aboute selection- that is exactly what I was doing- pressing a key, so it is the case that you described.
inserted: 2017-05-25 13:56:59   Reply...
From: см
I am trying unsuccesful to change the font of a dynamically created TKMemo. My code is below. Font keeps staying unchanged.
Changing the font from the Lazarus IDE works fine.
Changing the font of a statically created TKMemo works (but only if it is done before .Blocks.Clear is executed).

What could have gone wrong?

procedure TForm1.DynamicClick(Sender: TObject);
  MyMemo: TKMemo;
  ShowMessage ('aaa');
inserted: 2017-05-28 10:11:28   Reply...
From: tk
KMemo1.TextStyle.Font.Name := 'Elephant';
inserted: 2017-05-29 08:08:21   Reply...
From: см
inserted: 2017-05-19 09:37:10   Reply...
From: MCS-programmer
The great StrinGgrid component (Kgrid) is missing only Aligment for cells, rows and columns, and you need to improve the handling of the "OnDrawCell" (sometimes is smudging) event, and the ".CommaText" event does not work.
inserted: 2017-05-25 10:11:51   Reply...
From: tk
If you mean alignment of text in cells then it is fully supported via TKGridCellPainter.HAlign property. Yes it must be explicitly specified in OnDrawCell but I don't think this is too difficult to use:

procedure TMainForm.KGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; R: TRect; State: TKGridDrawState);
  G: TKGrid;
  G := TKGrid(Sender);
  // align text right in second column
  if ACol = 1 then
    G.CellPainter.HAlign := halRight;
  G.CellPainter.Text := G.Cells[ACol, ARow];

CommaText? Why? It is a TStringList property.
inserted: 2017-05-25 12:17:12   Reply...
From: mcs-programmer
Thanks for your reply, Ok, after applying this code i have something like this:
Undeclared identifier: 'halRight'
Also, I would like to set the alignment for single cells rather than for only declared columns and rows. And not in OnDrawCell, because the database I create already has too many functions there, and the database is not displayed correctly then.
inserted: 2017-05-28 10:02:18   Reply...
From: tk
You can also use TKGridAttrTextCell. In this case no OnDrawCell is needed:

procedure TForm1.FormCreate(Sender: TObject);
KGrid1.CellClass := TKGridAttrTextCell;
TKGridAttrTextCell(KGrid1.Cell[1,2]).HAlign:= halRight;
TKGridAttrTextCell(KGrid1.Cell[3,5]).HAlign:= halRight;
inserted: 2017-05-25 13:41:12   Reply...
From: см
Did you try to add „KGraphics‟ in the Uses section for solving the „Undeclared identifier: 'halRight'‟ issue?
inserted: 2017-05-25 19:38:01   Reply...
From: mcs-programmer
Thanks, my mistake, I did not think about it :)
inserted: 2017-05-19 09:05:51   Reply...
From: mangakissa
Nice tool for FPC users. Finally an adult TDBGrid.

Will KControls support Delphi D10.x in VCL mode?
inserted: 2017-05-25 09:45:44   Reply...
From: tk
In the repository Delphi D10.x support has been added long time ago.
inserted: 2017-05-12 01:09:49   Reply...
From: DanishMale

first of all thx for a great pack of components I am a happy user of your work THUMPS UP!!!!

Only got one tiny problem... How do I set a Fieldname at runtime in a KDBGRid ?

inserted: 2017-05-12 02:06:25   Reply...
From: DanishMale

forgot to say that I hav etried your solutions

TKDBGridCol(DBGrid1.Columns.Items[0]).FieldName := TEST_QUERY.Fields[ACol].FieldName;

TKDBGridCol(DBGrid1.Columns.Items[ACol]).FieldName := TEST_QUERY.Fields[ACol].FieldName;

both do not what is excepted :/
inserted: 2017-05-14 11:06:24   Reply...
From: tk
This is correct so maybe there is another problem. Design time setting works?
inserted: 2017-05-09 11:07:15   Reply...
From: Randell
How can I change thee default configuration for paper type to A4 rather than letter? I looked at the code but did not see configuration.
inserted: 2017-05-14 10:58:31   Reply...
From: tk
Normally in printer configuration dialog. It depends on used printer, not all printers can handle A4 format.
inserted: 2017-05-04 09:55:23   Reply...
From: см
I have tried the code below and and it occurs that KMemo1.SelLength returns negative values (for example, it returns -5 instead of 5). Is that the expected behaviour or is it a bug?

procedure TForm1.cmdTextPosClick(Sender: TObject);
  KMemo1.Blocks.AddTextBlock('Line 1');
  KMemo1.Blocks.AddTextBlock('Line 2');
  KMemo1.Blocks.AddTextBlock('Line 3');

procedure TForm1.KMemo1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  ShowMessage (KMemo1.SelText);
  ShowMessage (IntToStr(KMemo1.SelStart)+' ' +IntToStr(KMemo1.SelLength));
inserted: 2017-05-04 10:02:48   Reply...
From: см
Also, KMemo1.SelStart seems to return the position of the last selected character so it works as SelEnd, not as SelStart.
inserted: 2017-05-08 11:19:20   Reply...
From: tk
These values depend on where the selection begins and ends. To get absolute values, use RealSelLength, RealSelStart and RealSelEnd.
inserted: 2017-05-09 09:23:51   Reply...
From: см
Thanks for the info!
RealSel* behaves better.
But I have the following problem:

When using the aformentioned code to generate line 1 to 3 (2017-05-04 09:55:23) with the following code:

procedure TForm1.KMemo1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
  writeln (MidStr(KMemo1.Text,KMemo1.RealSelStart,KMemo1.RealSelLength));

When I select „Line 1‟ everything is fine.
But when I select „Line 1‟ together with the first „Li‟ from the second line I get on the screen

instead of

I also tried

procedure TForm1.cmdTextPosClick(Sender: TObject);
  KMemo1.Blocks.AddTextBlock('Line 1');
  KMemo1.Blocks.AddTextBlock('Line 2');
  KMemo1.Blocks.AddTextBlock('Line 3');
  ShowMessage (midstr(KMemo1.Text,0,6));
  ShowMessage (midstr(KMemo1.Text,0,7));
  ShowMessage (midstr(KMemo1.Text,0,8));
  ShowMessage (midstr(KMemo1.Text,0,9));

In this sample ShowMessage (midstr(KMemo1.Text,0,7)); and ShowMessage (midstr(KMemo1.Text,0,8)); display the same.
I found that RealSel* considers the NewLine as a single character, while it is most likely two charcters (#13#10). Maybe this is system dependent?

Or should I use something else instead of „Text‟ in „KMemo1.Text‟?
inserted: 2017-05-14 10:55:39   Reply...
From: tk
A paragraph mark is always taken as single selection entity. You should use SelText property to get selected text.
inserted: 2017-05-15 10:10:55   Reply...
From: см
I actually need to get the first several characters of the selected lines (which might not be completely selected).
So I was thinking to get the position of the selection, using .RealSelStart and to search back in KMemo1.Text for a #13#10 to find the beginnings of the lines.
What actually happens is that .RealSelStart considers paragraph mark as single character, while KMemo1.Text returns the paragraph as #13#10 and I cannot find where the selection is located within .Text.

What I could do is to use MidStr(StringReplace(KMemo1.Text,#13#10,#13,[rfReplaceAll, rfIgnoreCase]),KMemo1.RealSelStart,KMemo1.RealSelLength)); but it will actually take minutes.
I wonder if I could use KMemo1.ActiveBlocks.Text and if it would be faster?
Or should I use some other property instead of .Text?
Otherwise I cannot think of a possible practical usage of .RealSel*.

Also, since RTF is a MS format, I suppose that paragraph shall always be #13#10 (system independent).
inserted: 2017-05-15 16:26:11   Reply...
From: tk
StringReplace(KMemo1.Text,#13#10,#13,[rfReplaceAll, rfIgnoreCase]) should be fast, at least for reasonable long documents. If it isn't then there is something wrong with your document.

When replaced, the selection markers should match the text (provided there are no inline images etc. in the memo, which also take one selection position).

But you could also traverse lines of your document. Use KMemo1.ActiveBlocks.LineCount to get number of lines and KMemo1.ActiveBlocks.LineText to get text of each line.
Use KMemo1.ActiveBlocks.LineStartIndex and LineEndIndex to compare with KMemo1.RealSel* properties.
inserted: 2017-05-17 08:18:51   Reply...
From: см
Hi, thanks for the hints!

The following code for one of the cases:
    WriteLn('ActiveBlocks.LineCount= ' + IntToStr( KMemo1.ActiveBlocks.LineCount));
    WriteLn('StringLength= ' + IntToStr(Length(KMemo1.Text)));
    WriteLn('StringLengthAB= ' + IntToStr(Length(KMemo1.ActiveBlocks.Text)));
    WriteLn('Replacement started at ' + IntToStr(GetTickCount64));
    WriteLn('Replacement done at ' + IntToStr(GetTickCount64));

resulted in
    ActiveBlocks.LineCount= 0
    StringLength= 3991513
    StringLengthAB= 3991513
    Replacement started at 689619548
    Replacement done at 689699467 (79,919 seconds)

Considering that some of the documents are bigger, replacement will be really painful.
I have no clue why ActiveBlocks.LineCount returns 0. The entire document is displayed in a single table, maybe that causes the confusion.

If I understand you right, I cannot use „Use KMemo1.ActiveBlocks.LineStartIndex and LineEndIndex to compare with KMemo1.RealSel* properties.‟ without replacing new lines?
I will think for some workaround.
inserted: 2017-05-18 10:45:14   Reply...
From: tk
If the document has only one big table then you would need to traverse lines in individual cells. Instead of KMemo1.ActiveBlocks you would need to use YourTable.Cells[Column, Row].Blocks.

Getting KMemo1.Text should be fast though. Maybe StringReplace itself is slow for such a long string?

var S: string;
S := KMemo1.Text;

What line is slow?

I would need to see the document to say why KMemo1.ActiveBlocks.Linecount is zero. If the document has only one big table with mbpText position then it should be 1.
inserted: 2017-05-19 15:16:35   Reply...
From: см
S := KMemo1.Text; took 1,3 s.
StringReplace(S,#13#10,#13,[rfReplaceAll]); took 104,5 s

I wrote the code below and
   1. WriteLn (LazUTF8.UTF8Copy(... returns the selected contents, which seems okay.
   2. WriteLn ('linecount='+IntToStr (TKMemoTableCell(Block).Blocks.LineCount)); returns the number of selected lines if they belong to a SINGLE cell. If they belong to more than one cell it returns 1.
So it seems that .LineText is not applicable when multiple cells are selected. I am still not sure that method 1 won't be slow on bigger tables (my cells are not big).
I still have not made tests with bigger tables, I will feedback later.

What I noticed is that when I drag the mouse vertically, not only the cells of the same columns are selected, but also from the neighbouring columns.
When I drag the mouse horizontally, only cells of the same row are selected.
MS Word and Excel (I cannot check other similar apps) do not behave like this- when the mouse is dragged only vertically, only cells of the same column are selected.

procedure TForm1.KMemo1BlockClick(Sender: TObject; ABlock: TKMemoBlock; var Result: Boolean);
  Block: TKmemoBlock;
  S: string;
  LineIndex: integer;
  FirstLine, LastLine: string;
  Block := ABlock;
  while (Block <> nil) and not (Block is TKMemoTableCell) do
    Block := Block.ParentBlocks.Parent;
  if Block <> nil then
    WriteLn (LazUTF8.UTF8Copy(S,TKMemoTableCell(Block).Blocks.RealSelStart+1,TKMemoTableCell(Block).Blocks.RealSelLength));
    WriteLn ('linecount='+IntToStr (TKMemoTableCell(Block).Blocks.LineCount));
    if TKMemoTableCell(Block).Blocks.LineCount>0 then
       for LineIndex:=0 to TKMemoTableCell(Block).Blocks.LineCount-1 do
         if (TKMemoTableCell(Block).Blocks.RealSelStart>=TKMemoTableCell(Block).Blocks.LineStartIndex[LineIndex])
           and (TKMemoTableCell(Block).Blocks.RealSelStart<=TKMemoTableCell(Block).Blocks.LineEndIndex[LineIndex])
           then FirstLine:=TKMemoTableCell(Block).Blocks.LineText[LineIndex];
         if (TKMemoTableCell(Block).Blocks.RealSelEnd>=TKMemoTableCell(Block).Blocks.LineStartIndex[LineIndex])
           and (TKMemoTableCell(Block).Blocks.RealSelEnd<=TKMemoTableCell(Block).Blocks.LineEndIndex[LineIndex]) then
           end; //if
       end; //for
    end; //if
    WriteLn ('FirstLine=' + FirstLine);
    WriteLn ('LastLine=' + LastLine);
    Result := True;
inserted: 2017-05-19 15:29:26   Reply...
From: см
I forgot to mention, that s:=StringReplace(Block.Text,#13#10,#13 is not fine, new paragraph should be converted to #10 instead. Anyway, to evade suprices, the #10 should better be replaced back to #13#10.
Also, .LineText return the line with the NewLine chracters included. Should it be this way?
inserted: 2017-05-25 09:43:57   Reply...
From: tk
Everything is ok then. You maybe have to write your own, faster variant of StringReplace. Each cell is a container which has own blocks and lines. Table selection behaves only such way, no column only selection is possible.
inserted: 2017-05-25 13:48:50   Reply...
From: см
I have implemented it with .Blocks.Line*Index and Blocks.LineText[] and seems to work fine without replacing paragraph marks.
Selecting lines from different does seem to make sense (at least until now) for my application.
inserted: 2017-05-15 11:06:10   Reply...
From: см
It occurs that MidStr won't do at all. It returns number of bytes, not numbers of characters (so it won't work with unicode). I am searching a proper function and I will feed back later.
inserted: 2017-05-15 13:19:56   Reply...
From: см
I tried the code below (in Lazarus), now non-latin characters are handled properly, but #13 and #10 are still considered separate characters (which seems fine to me, since they have separate purpose). Maybe Delphi acts differently?

for i:=1 to Length(content) do
    WriteLn (crchar);
inserted: 2017-05-02 07:27:14   Reply...
From: Randell
I am installing KControls. I got 'Fatal:Cannot find KRes used by KGraphics of package KControlsLaz.' I am using Lazarus 1.6.0. Help
inserted: 2017-05-06 14:43:03   Reply...
From: Randell
Downloaded from Bitbucket and it had missing file. It installed and I have started playing with the controls.
inserted: 2017-05-08 11:15:44   Reply...
From: tk
Until now KRes.pas was missing in both packages but it always worked for me. Now I included it in kcontrolsbase.lpk.
inserted: 2017-04-28 00:16:34   Reply...
From: josh
Installed latest lazarus trunk (1.9)
Download kcontrols from bitbucket
I cannot install, errors out kgrids 2942 with
kgrids.pas(2942,15) Error: There is no method in an ancestor class to be overridden: "DoAutoAdjustLayout(const TLayoutAdjustmentPolicy;const Double;const Double;const Boolean);"

{$IF lcl_fullversion >= 1080000}
    procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
      const AXProportion, AYProportion: Double; const AScale0Fonts: Boolean); override;
inserted: 2017-04-28 11:53:13   Reply...
From: tk
It seems that Lazarus developers modified the ancestor class in the trunk. Simply delete that method or change the ifdef so that you can compile. I'll check it when I need to update Lazarus from trunk.
inserted: 2017-04-17 09:18:48   Reply...
From: CT

Is it possible to do grouping in KDBgrid ?

inserted: 2017-04-26 23:15:25   Reply...
From: tk
What is grouping?
inserted: 2017-04-05 15:37:53   Reply...
From: см
I cannot find a way to disable text wrapping for a text block or a table cell.
   TKMemoTextBlock.WrapMode is read only;
   TKMemoTextBlock.WordBreakStyle has no option NoBreak;
   TKMemoTextBlock.WordBreaks is read only;
Could there be a way to disable wrapping?
inserted: 2017-04-07 14:27:18   Reply...
From: tk
This is possible only for a whole paragraph, with TKMemoParagraph.ParaStyle.WordWrap.
inserted: 2017-04-07 15:05:38   Reply...
From: см
I just found that
disables wrapping (sample below). But according your explanation, is this the expected behaviour?

procedure TForm1.Button4Click(Sender: TObject);
  MyTable: TKMemoTable;
  MyBlock: TKMemoTextBlock;
   MyBlock:=MyTable.Cells[2,2].Blocks.AddTextBlock('asdfljlkslkdflksjdflkasjkldsj kldfsklajdskladkljdksjldjklsdakjlkjdlfkasjldkdjfljkasdjkldaskjldkjlsdajkldsajkldsjk;ldsajkl;dsakjl;sadjkl;daskjl;daskjl;adsfjk;lreiotoietyitetiuoetuietieiptuoiupoteiupofljkjfskfgsdjjfksd;jkfldj;,.m');
inserted: 2017-04-07 16:10:13   Reply...
From: см
And this disables wrapping for a cell of a table:

if aMemoTable.Rows[Row].Cells[Column].Blocks.Count>0 then
  for BlockIndex:=0 to aMemoTable.Rows[Row].Cells[Column].Blocks.Count-1 do
   if aMemoTable.Rows[Row].Cells[Column].Blocks[BlockIndex] is TKMemoTextBlock
then TKMemoTextBlock(aMemoTable.Rows[Row].Cells[Column].Blocks[BlockIndex]).WordBreakStyle:=wbsFirstWordChar;
inserted: 2017-04-26 23:14:55   Reply...
From: tk
Actually wbsFirstWordChar has not been tested yet.
I am pretty sure it now equals 'wbsNoBreak' because under normal circumstances the condition CharInSetEx(S[1], [cTAB] + Wordbreaks), now present in TKMemoTextBlock.GetWordBreakable, always returns False.

inserted: 2017-04-27 10:20:34   Reply...
From: см
Actually currently there is no parameter, named „wbsNoBreak‟ but IMHO, it would be useful.
inserted: 2017-04-04 13:39:12   Reply...
From: Ian
When we set EditorMode to False in TKGrid, if there is not text in the editor control then an exception is raised.

I have tracked the problem to GetControlText which is in KControls. Within this function is GetTextBuf. Before the line Value.GetTextBuf(...) I have added:
if Length(Result) > 0 then

This has stopped the exception.
inserted: 2017-04-04 21:21:40   Reply...
From: tk
Thanks, I will apply your patch in next commit.
inserted: 2017-04-05 11:47:34   Reply...
From: Ian
Glad I could contribute, even if in such a small way.

Thank you for such a great component.
inserted: 2017-03-30 16:47:55   Reply...
From: Sat1
Dobry den, existuje prosim nejaka moznost jak nastavit sirku sloupcu DBGridu v kodu? Klasicka moznost DBGrid1.Columns[i].Width neni.
Dale prosim o radu zda lze v sloupci zobrazit hodnoty v comboboxu, nebo listboxu.
Moc dekuji
inserted: 2017-03-31 14:18:11   Reply...
From: tk
Please speak English here so that others can read this thread.

1. In KDBGrid there is TKDBGrid.Columns[I].Extent (or classic TKDBGrid.ColWidths[I] instead of TDBGrid.Columns[i].Width.

2. You can show/edit cells in combobox or listbox with KDBGrid. You just have to create and use custom inplace editors for respective columns. Look at KGrid demo (event chain OnEditorCreate, OnEditorDataFromGrid, etc.) or maybe best at methods TKDBGrid.DefaultEditorCreate, TKDBGrid.DefaultEditorDataFromGrid etc.
inserted: 2017-03-27 14:37:15   Reply...
From: см
In Lazarus, I am trying to resize an image and then add it into a TKMemo with the code below. For some reason only an empty rectangle is shown.
Could it be me doing something wrong or there is a problem in TKMemo?
When I add the downscaled image to Image1: TImage; it is displayed just fine.

procedure TForm1.Button1Click(Sender: TObject);
  ImagePicture: TPicture;
  bmp: TBitmap;
  ImagePicture:= TPicture.Create;

    bmp := TBitmap.Create;
    bmp.Width := Round(ImagePicture.Width /4);
    bmp.Height:= Round(ImagePicture.Height/4);
    bmp.Canvas.StretchDraw(Rect(0,0, Round(ImagePicture.Width /4), Round(ImagePicture.Width /4)), ImagePicture.Graphic);
    bmp.SaveToFile ('c:\scaled_image.png'); //Downscaled image is stored to a file as expected

  Image1.Picture:= ImagePicture; //Downscaled image is displayed fine in Image1
  KMemo1.Blocks.AddTextBlock ('Image top');
  KMemo1.Blocks.AddImageBlock(ImagePicture); //An empty rectangle is added in KMemo1
  KMemo1.Blocks.AddTextBlock ('Image bottom');
inserted: 2017-03-31 14:05:11   Reply...
From: tk
TBitmap is not supported in KMemo. Convert the downscaled image to PNG and load it to KMemo.
inserted: 2017-04-04 16:34:48   Reply...
From: см
Thanks, I downscaled to PNG directly and it works.
inserted: 2017-03-25 10:09:03   Reply...
From: taazz
There is a small bug in the TKPageControl component in lazarus. A number of SigsegV exceptions are raise when ever a tabsheet is destroyed after it was placed inside a kpagecontrol. The problem comes form the TTabSheets class which is based on the TObjectlist which in turn has the OwnsObjects property set to true by default. Every a TKtabsheet is removed from the pagecontrol it is automatically destroyed and in most cases a second call free follows which raises the exceptions.
inserted: 2017-03-31 14:03:01   Reply...
From: tk
TKPagecontrol has not yet been fully finished and tested in Lazarus.
inserted: 2017-05-04 08:47:15   Reply...
From: valdir
I am trying to use TKPagecontrol from both KControls 1.7 stable and latest unstable from versions and the component is not working on Lazarus 1.6.4.

Should I use Lazarus 1.8 to overcome those erros?

inserted: 2017-05-18 10:50:08   Reply...
From: tk
You would need to fix TKPagecontrol to work with LCL. It is not ready for use in Lazarus yet. We've been using it only in Delphi so far, there it works fine.
inserted: 2017-03-15 13:21:00   Reply...
From: см
Hi Tk,
I have some problems with
Something after calling it after resizing the memo the memo is not displayed at all.
I changed the code to
   if (Memo.BorderStyle<>bsNone) then Memo.BorderStyle:=bsNone;
and now prolems seem to be gone, but I assume that this check should be done internally.
inserted: 2017-03-20 10:15:33   Reply...
From: tk
Is it only Lazarus issue? Or happens in Delphi as well?
inserted: 2017-03-21 06:54:49   Reply...
From: см
I have observed it only in Lazarus, I cannot test in Delphi.
I will try to create a reproducing code, if you would consider it necessary?
inserted: 2017-03-21 07:55:02   Reply...
From: см
Below is the code, that demonstrates the issue. Just click on the titlebar to maximize the window. After uncommenting {if (ReportMemo.BorderStyle<> bsNone) then} behaviour seems fine.

unit Unit1;

{$mode objfpc}{$H+}


  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, kdbgrids,


  { TForm1 }

  TForm1 = class(TForm)
    ReportMemo: TKMemo;
    procedure FormResize(Sender: TObject);
    { private declarations }
    { public declarations }

  Form1: TForm1;


{$R *.lfm}

{ TForm1 }

procedure TForm1.FormResize(Sender: TObject);
  NewWidth, NewHeight: integer;
  NewWidth:= self.Width-10;

  {if (ReportMemo.BorderStyle<> bsNone) then} ReportMemo.BorderStyle:=bsNone;

inserted: 2017-03-21 08:10:07   Reply...
From: см
Sorry, I should heve written of „Just DOUBLE click on the titlebar‟ instead of „Just click...‟
inserted: 2017-03-21 20:10:53   Reply...
From: tk
This is a Lazarus/LCL bug and occurs even with normal TMemo. In Delphi XE this behaves just fine. Please report this problem to Lazarus bugtracker.
inserted: 2017-03-23 07:59:51   Reply...
From: см
inserted: 2017-03-09 12:22:14   Reply...
From: см
Hi TK,
Executing Memo.Visible is very slow when content is huge.
Using .lockupdate and .unlockupdate makes things signifficantly faster.
Maybe they could be added in the .Visible routine?
inserted: 2017-03-20 10:14:45   Reply...
From: tk
I cannot see the difference but it is possible to add this.
inserted: 2017-03-05 16:25:33   Reply...
From: uvs
I try install on C++ Builder XE7 and have error:
"can't be installed because it was created with a different version of delphi or c++ builder"
Build is success.
inserted: 2017-03-06 09:09:28   Reply...
From: tk
And installation in Delphi XE7 works?
inserted: 2017-03-06 19:25:24   Reply...
From: uvs
I havn't Delphi. I try only C++ Builder.
inserted: 2017-03-07 08:21:57   Reply...
From: tk
Then I don't know what is the reason and you'll have to figure it out yourself. There is full source available, so it should work. I don't use /have C++ Builder at all now. I only tried in C++ Builder XE some years ago, there it worked so I assumed it would install in later versions as well.
inserted: 2017-03-02 08:33:25   Reply...
From: Deyan
Hello. I am testing TKMemo component on Lazarus IDE v1.6.2 , Ubuntu 16.04. I just put TKMemo, TKPrintSetupDialog, TKPrintPreviewDialog.
My questions are:
1. How to pre-setup the values of PrintSetupDialog, before to call it? Ex:I want margins left,right,top,bottom to be =0 by default
2. I put simple text in the memo Ex: Hello world. The print result is always with BLACK background (negative). Same test under Windows and Delphi7 is OK
inserted: 2017-03-02 10:28:31   Reply...
From: tk
Don't even try to print under GTK2 in Lazarus. There are lot of problems in that widgetset. Previewing works but printing not (at least to the extent I need for KControls). You can try QT, it should be better but I don't remember that exactly anymore. Or you can try to fix the problems in the GTK2 widgetset yourself.
inserted: 2017-02-23 22:02:01   Reply...
From: Josh
Having an issue changing font in tkgrid, using latest LAZ/FPC trunk and latest kcontrols from here.
I cannot change the font for the grid, if I change the grid font to something like Eurostile it does not alter visually, if I change the font for say a memo or stringgrid these change the accordingly.
I have tried setting the font in ide and in code, ie in form create'Eurostile'; this has no effect either.

Ant ideas; or is this not supported and I have to change the font for each cell in OnDrawCell.
inserted: 2017-02-23 22:25:50   Reply...
From: Josh
I think I have figured it out. The parentfont property must be set to false to allow overriding of the Font Property; StringGrid Memo etc do not require this property to be set to false to allow font re-assignment. So did not think about about.
It occurred when I saved a project that I had changed the font to, and when I reopened it the font was set to default.
inserted: 2017-02-28 09:36:36   Reply...
From: tk
I've fixed it in the trunk. It works now both in KGrid and KMemo. Font size changes in KGrid at design time need reopening the form to update the row height.
inserted: 2017-02-14 19:22:24   Reply...
From: frank
I check the trunks on bitbucket... but there are so many changes since 1.7 that I have am not going to download each individual file.

Don't you have the latest build with all files??
I want to re-install the entire package with updated files.
inserted: 2017-02-14 21:56:38   Reply...
From: tk
You must pull to your local repository or download entire repository (link under Downloads section). You are not working with github or bitbucket?
inserted: 2017-02-13 11:04:12   Reply...
From: kosthala
I'm trying to install kcontrols in Delphi 2007 and i get error:
[Pascal Error] kbuttons.pas(144): E2147 Property 'ParentDoubleBuffered' does not exist in base class.

Can you help me?
inserted: 2017-02-13 16:53:30   Reply...
From: tk
Hmm, it seems that ParentDoubleBuffered has been added in Delphi 2009 first and not in 2007 as I assumed. In that case its declaration in TKCustomControl is wrong and it should be:
    property ParentDoubleBuffered: Boolean read FParentDoubleBuffered write FParentDoubleBuffered default True;

I'll fix this on next occasion.

Unfortunately, for all newly added properties, the version of their addition to VCL is missing in Embarcadero documentation...
inserted: 2017-02-12 12:15:54   Reply...
From: array81
Does KMemo support header and footer?
inserted: 2017-02-12 16:22:11   Reply...
From: tk
If you mean editable header and footer that is also saved to RTF, like in Word, then this is not supported (and is far from being supported in near future), along with paging, sections etc., all are big TODOs.

Now it is only possible to add custom code to OnPrintPaint event, for preview/print. There custom header or footer might be added for each page. An example is shown in the KGrid demo.
inserted: 2017-02-11 13:39:30   Reply...
From: frank
Does KMemo support copy and paste of images? Because I can't seem to paste an image from clipboard into a block
inserted: 2017-02-11 20:36:32   Reply...
From: tk
It was not supported but I've added it just now. Copy&paste to Kmemo now works for RTF, plain text and images, copy&paste from Kmemo was not modified, is RTF and plain text only. Maybe here in future the first selected image could be inserted to clipboard as well (or if just one image block is selected).
inserted: 2017-02-10 17:01:28   Reply...
From: frank
KMemo... I have s test string 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.... when the width of the memo is made narrow... that long text string doesn't wrap, but goes off screen. Yet, I don't want horz scrollbar.
inserted: 2017-02-11 02:24:31   Reply...
From: frank
Also.. when it doesn't wrap the scrollbar doesn't show either
inserted: 2017-02-11 10:06:31   Reply...
From: см–
Did you try the latest release from bitbucket?
AFAIR a problem with the scrollbars was fixed a few weeks ago.
inserted: 2017-02-11 13:30:36   Reply...
From: frank
I downloaded the one from this site. What is the URL for bitbucket? There is no link on this site I can see.
inserted: 2017-02-11 13:33:13   Reply...
From: frank
found the link
inserted: 2017-02-10 11:23:46   Reply...
From: см
I am trying to add a TKMemoTable.Assign property to assign tables, at leastin the extent that I need.
Merging cells seem to work, there is some problem with cell borders, for which I have a workaround, but I cannot make ColumnWidths works, which is a signifficant problem for me.
Any hint how to make ColumnWidths work will be appreciated.
It does not work even after the table is created, assigned and displayed.

Code is below:

procedure TKMemoTable.Assign(ASource: TKObject);
  Row: integer;
  Clm: integer;
  SourceTableCell: TKMemoTableCell;
  ColWidth: integer;
  if ASource is TKMemoTable then
      for Clm:= 0 to TKMemoTable(ASource).ColCount-1 do
        for Row:= 0 to TKMemoTable(ASource).RowCount-1 do

          //None of these are not working


  // ApplyDefaultCellStyle; //This is fine for my needs, but not in general
          //END These are not working

          Cells[clm,row].BlockStyle.Brush:=SourceTableCell.BlockStyle.Brush; //Copy background colour
        end; //for Row

        if (ColWidth>0) then ColWidths[clm]:= ColWidth;

       end; //for clm
  end; //if
inserted: 2017-02-10 15:47:18   Reply...
From: tk
It has been already implemented, today I commited the changes. With those, at least your code below worked for me.
inserted: 2017-02-14 07:51:28   Reply...
From: см
I have tried it and so far it seems to works okay.
inserted: 2017-02-14 09:15:10   Reply...
From: см
As I used it more a problem ocurred:
When executing the code below the application crashes on line CellPos:= KMemo1.BlockRect(CellBlock); . Without using assignments, nothing crashes, positioning is on the expected row (although the column is 1 column wrong).

procedure TForm1.Button6Click(Sender: TObject);
    Table: array of TKMemoTable;
    row, clm: integer;
    DispTable: TKMemoTable;
    MergeSpan: TKCellSpan;
    CellBlock: TKMemoBlock;
    CellPos: TRect;
  DispTable:= KMemo1.Blocks.AddTable;
  Table[0]:= TKMemoTable.Create;
    for row:=0 to Table[0].RowCount-1 do
      for clm:=0 to Table[0].colCount-1 do
        Table[0].Cells[clM,row].Blocks.AddTextBlock ('Table'+IntToStr(0)+'Line'+IntToStr(row) +'Column'+ IntToStr(clm)) ;


    CellPos:= KMemo1.BlockRect(CellBlock);
    kmemo1.ExecuteCommand(ecGotoXY, @CellPos.TopLeft);
inserted: 2017-02-16 21:24:57   Reply...
From: tk
When you call Assign a COPY of the table Table[0] is inserted to the memo. This is again one of the VCL/LCL basic principle. I hope here again you can see the bug you've made.

But I had bug in KMemo1.BlockRect as well - it should return zero point instead of exception, when the block was not found in the memo. I'll fix this on next occasion.
inserted: 2017-02-08 23:19:40   Reply...
From: Woj
I can't set color for select bar in tkdbgrid.
I use "gdSelected in State" in OnDrawCell event but color don't change.
inserted: 2017-02-09 09:19:23   Reply...
From: Woj
I've found something. If I disable "goThemedCells" option then coloring in selection bar works, but I don't want to disable it. It looks like old school.
inserted: 2017-02-09 20:46:53   Reply...
From: tk
In goThemedCells mode KGrid uses Vista style selection (that looks fine in Vista and 7 but ugly in 10). If you want to disable it you either have to turn off goThemedCells or draw your cell on your own (not via CellPainter.DefaultDraw).
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