Recent

Author Topic: Kgrid inplace editor  (Read 12660 times)

v4v4n

  • New member
  • *
  • Posts: 7
Kgrid inplace editor
« on: May 15, 2011, 07:38:22 am »
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

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Kgrid inplace editor
« Reply #1 on: May 15, 2011, 01:38:13 pm »
I don't have TAdvStringGrid nor KGrid installed. With normal TStringGrid you can place TEdit somewhere and write:
Code: [Select]
procedure TForm1.StringGrid1SelectEditor(Sender: TObject; aCol, aRow: Integer; var Editor: TWinControl);
begin
  Editor:=Edit3;
  Editor.Top:=aRow*StringGrid1.DefaultRowHeight;
  Editor.Left:=aCol*StringGrid1.DefaultColWidth;
end; 
Edit3 will be displayed in selected Cell. I can have any code in Edit3Change method and it works as expected.
Example (this changes window title immediately):
Code: [Select]
procedure TForm1.Edit3Change(Sender: TObject);
begin
  Caption:=Edit3.Text;
end; 
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

v4v4n

  • New member
  • *
  • Posts: 7
Re: Kgrid inplace editor
« Reply #2 on: May 15, 2011, 04:19:33 pm »
oke thanks...... so i will take stringgrid instead of Kgrid.......

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Kgrid inplace editor
« Reply #3 on: May 15, 2011, 05:01:27 pm »
To be fair, I had KGrid installed but I never deeply tested it (I didn't try inplace editor). It is more powerful component than TStringGrid and its author says that it has 95% compatibility with TStringGrid and "Any TWinControl descendant can be used as inplace editor." - http://www.tkweb.eu/en/delphicomp/kgrid.html
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

v4v4n

  • New member
  • *
  • Posts: 7
Re: Kgrid inplace editor
« Reply #4 on: May 16, 2011, 02:56:37 am »
hi blaazen

yes i have come to that page. i'm in the progres migrate from delphi to lazarus.
so i need to find the replacement grid for TAdvstringgrid from TMS in lazarus. i read that Kgrid is powerful. but it's very lack of example and documentation. and i'm still looking for another grid. do you have any suggestion ?

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Kgrid inplace editor
« Reply #5 on: May 16, 2011, 01:51:33 pm »
I installed the latest KGrid (v. 1.7) and works. The big *.zip from author contains *.lpk (as well as *.dpk) files and also *.pdf file where inplace controls are well documented.
Inplace editor works differently than with TStringGrid. When you need inplace editor you must use event:
Code: [Select]
OnEditorCreate
- here you create TEdit, TButton or whatever
Following example is with TSpinEdit:
Code: [Select]
procedure TForm1.KGrid1EditorCreate(Sender: TObject; ACol, ARow: Integer;
  var AEditor: TWinControl);
begin
  AEditor:=TSpinEdit.Create(nil);
end;

procedure TForm1.KGrid1EditorDataFromGrid(Sender: TObject;
  AEditor: TWinControl; ACol, ARow: Integer; var AssignText: Boolean);
var s: string;
begin
  s:=KGrid1.Cells[aCol, aRow];
  if s='' then TSpinEdit(AEditor).Value:=0
    else TSpinEdit(AEditor).Value:=strtoint(s);
end;

procedure TForm1.KGrid1EditorDataToGrid(Sender: TObject; AEditor: TWinControl;
  ACol, ARow: Integer; var AssignText: Boolean);
begin
  KGrid1.Cells[aCol, aRow]:=inttostr(TSpinEdit(AEditor).Value);
end;

Author says that it is not necessary do anything in
Code: [Select]
OnEditorDestroy and seems true (I checked with heaptrace).
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

v4v4n

  • New member
  • *
  • Posts: 7
Re: Kgrid inplace editor
« Reply #6 on: May 17, 2011, 03:20:17 am »
thanks blaazen

i will try it....then i will post it again if i have problem on it.....

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Kgrid inplace editor
« Reply #7 on: May 17, 2011, 07:08:56 am »
Blaazan, did you have to do anything special to get KGrid to work?  I can use it on a Form but when I end the program I get "RunError(32032)" every time.  I think I remember you use Linux, but I use Windows 7.
Lazarus Trunk / fpc 2.6.2 / Win32

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Kgrid inplace editor
« Reply #8 on: May 17, 2011, 01:24:59 pm »
Blaazan, did you have to do anything special to get KGrid to work?  I can use it on a Form but when I end the program I get "RunError(32032)" every time.  I think I remember you use Linux, but I use Windows 7.
No, nothing special, I downloaded the latest version of KGrid and worked (I mainly tried inplace editor). Yes, I am on Linux - 64 bit.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Kgrid inplace editor
« Reply #9 on: May 17, 2011, 01:35:30 pm »
Thanks Blaazan.  I can't get it to terminate properly.
Lazarus Trunk / fpc 2.6.2 / Win32

 

TinyPortal © 2005-2018