Topic: Locking Table lenghts in place

hey guys, is there a way to "lock" table sizes in place? i have to readjust everything after i restart the app

Re: Locking Table lenghts in place

Hello Vasco,


I usually set the desired size of my columns in the OnChange event of the Tablegrid, this way, each time new data are loaded in it, the size remain the same :

procedure vendors_TableGrid1_OnChange (Sender: string);
begin
    vendors.TableGrid1.Columns[0].Width := 120;
    vendors.TableGrid1.Columns[1].Width := 200;
    vendors.TableGrid1.Columns[2].Width := 70;
    vendors.TableGrid1.Columns[3].Width := 70;
end;

For text alignment in the columns or the headers of the columns you can do :

procedure Form1_TableGrid1_OnChange (Sender: string);
begin
     Form1.TableGrid1.Columns[0].Alignment := taRightJustify; // first column
     Form1.TableGrid1.Columns[1].Alignment := taCenter; 
     Form1.TableGrid1.Columns[2].Alignment := taLeftJustify; 

     Form1.TableGrid1.Columns[1].Header.Alignment := taCenter; //this is for the header text
end;

Hiding a column :

procedure Form1_TableGrid1_OnChange (Sender: string);
begin
    Form1.TableGrid1.Columns[2].Visible := False;
end;

And accessing the value of the hidden column :

procedure Form1_TableGrid1_OnCellClick (Sender: string; ACol, ARow: Integer);
var
    sValue: string;
begin
    sValue := Form1.TableGrid1.Cells[2,ARow];
end;

Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Locking Table lenghts in place

Also you can disable to change columns size

procedure Form1_TableGrid1_OnChange (Sender: string);
begin
    Form1.TableGrid1.Columns[0].Width := 120;
    Form1.TableGrid1.Columns[0].Options := Form1.TableGrid1.Columns[0].Options + coFixedSize;
end;
Dmitry.

4 (edited by VascoMorais 2017-08-26 11:06:41)

Re: Locking Table lenghts in place

oh boy oh boy, here i go programming again!

https://i.imgflip.com/1urggi.jpg

Thanks guys!