Recent

Author Topic: Kgrid readonly col  (Read 3881 times)

jimmio

  • New member
  • *
  • Posts: 8
Kgrid readonly col
« on: July 10, 2013, 01:25:51 pm »
How do I set readonly properties in Kgrid columns ?? :(

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Kgrid readonly col
« Reply #1 on: July 10, 2013, 01:54:02 pm »
AFAIK only in code.
Code: [Select]
KGrid1.Cells[1, 0] := 'Sdfg';
You can also make fixed cols editable. You need to set:
KGrid1.Options.goEditing := True;
KGrid1.OptionsEx.gxEditFixedCols := True;

EDIT: I probably misunderstood, you wrote "readonly properties" and not "readonly cells". What readonly properties do you mean?
« Last Edit: July 10, 2013, 02:51:05 pm by Blaazen »
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/

jimmio

  • New member
  • *
  • Posts: 8
Re: Kgrid readonly col
« Reply #2 on: July 11, 2013, 06:46:32 am »
i have a kgrid component in a form with seven columns.
The first two columns loaded from file via the loadfromcvs, and the
next five columns display some results from the first two columns.
I want those five columns not to be editable or stop the tab .....

wp

  • Hero Member
  • *****
  • Posts: 13334
Re: Kgrid readonly col
« Reply #3 on: July 11, 2013, 09:31:36 am »
I don't know about KGrid, but in the standard TStringGrid you set the ReadOnly of the corresponding columns to true.

jimmio

  • New member
  • *
  • Posts: 8
Re: Kgrid readonly col
« Reply #4 on: July 11, 2013, 10:08:05 am »
Ι know about stringgrid, but i want to use Kgrid's cellspan property.
stringgrid does not have that property ....
Kgrid has not columns property ....

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Kgrid readonly col
« Reply #5 on: July 11, 2013, 12:18:24 pm »
KGrid probably cannot do it (or I don't know how). When you set (goEditing = False) it is in fact read-only grid.
I don't have so many experience with TKGrid but I think you can have:
1) Read only grid OR
2) Fixed Columns are read only and other cells are editable OR
3) All cells editable including fixed columns

depend on settings I mentioned above.
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/

jimmio

  • New member
  • *
  • Posts: 8
Re: Kgrid readonly col
« Reply #6 on: July 11, 2013, 12:37:28 pm »
i think that this may work, but i don't like it very much....    >:D

procedure TForm1.FormCreate(Sender: TObject);
begin
  kgrid1.Options :=kgrid1.Options + [goediting]-[goentermoves]+[gotabs];
  kgrid1.Cols[3].TabStop :=false;
  kgrid1.Cols [4].TabStop :=false;
kgrid1.Cols[5].TabStop :=false;
  kgrid1.Cols [6].TabStop :=false;
kgrid1.Cols[7].TabStop :=false;
end;   

wp

  • Hero Member
  • *****
  • Posts: 13334
Re: Kgrid readonly col
« Reply #7 on: July 11, 2013, 02:10:01 pm »
As I said I don't know anything about KGrid, but TStringGrid allows to specify a custom editor for each cell. This is done in the handler for the event OnSelectEditor. The following code, for example, makes all cells in column 1 read-only:

Code: [Select]
procedure TForm1.StringGrid1SelectEditor(Sender: TObject; aCol, aRow: Integer;
  var Editor: TWinControl);
begin
  if (ACol = 1) then
    Editor := nil;
end; 
Maybe a similar mechanism exists for KGrid.

jimmio

  • New member
  • *
  • Posts: 8
Re: Kgrid readonly col
« Reply #8 on: July 12, 2013, 11:24:58 am »
thanks wp
solution .....
Code: [Select]
procedure TForm1.KGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
  var CanSelect: Boolean);
begin
  if (ACol = 3)  then
    canselect:=false;
end;

 

TinyPortal © 2005-2018