Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

How to stretch last column width in TElTreeStringGrid

Hi,

I have a requirement to stretch the width of the last column in a TElStringGrid to fill the remaining space in the control, and where necessary wrap text within the cell. Is this possible? 

I have managed to trap the resize grid event and re-calculate the width of the last column successfully (see below), however I still want to allow the user to resize the other columns as well. 

procedure TfrmLog.ResizeGrid;
var
  colWidth : integer;
  i : integer;
begin
  if grid.HeaderSections.Count > 0 then begin

    // set width of last column based on width of other columns and control width
    colWidth := grid.ClientWidth;
    for i := 0 to grid.HeaderSections.Count-2 do begin
      Dec(colWidth, grid.HeaderSections[i].Width+3); // 3 = 1 for grid line, 2 for borders
    end;
    grid.HeaderSections[grid.HeaderSections.Count-1].Width := colWidth-1;
  end;
end;

Is this possible ? If so how ?

I'm using LMD ElPack 2019.12 with Delphi 10.3 RIO

Thanks

Tagged:

Comments

Sign In or Register to comment.