set wwdbgrid widths programmatically

Comments

4 comments

  • David Cornelius

    You can use either the ColWidths or ColWidthsPixels properties of the wwGrid to set the column widths at runtime.

    0
    Comment actions Permalink
  • Gary W Good

    I tried colwidths with no effect

    0
    Comment actions Permalink
  • David Cornelius

    Hmm...  Well, I mentioned ColWidths because that's what I read in the help file: "Set ColWidths at runtime to change the width of an individual column."

    But here's a procedure I've called from a form's OnResize even handler which does work:

    procedure TMyMainForm.AdjustLastGridColumn(wwGrid: TwwDBGrid);
    var
       TotalColumnWidth: Integer;
    begin
       TotalColumnWidth := 0;

       for var i := 0 to wwGrid.GetColCount - 2 do begin
          TotalColumnWidth := TotalColumnWidth + wwGrid.ColWidthsPixels[i];
       end;

       wwGrid.ColWidthsPixels[wwGrid.GetColCount - 1] := Width -
    TotalColumnWidth - 20 - { "20" for a little extra padding }
         GetSystemMetrics(SM_CXVSCROLL) -
    GetSystemMetrics(SM_CYBORDER) * 2 -
        GetSystemMetrics(SM_CXSIZEFRAME) * 2 -
    GetSystemMetrics(SM_CXPADDEDBORDER) * 2;
    end;
    0
    Comment actions Permalink
  • Gary W Good

    I finally realized that I needed to programmatically add Selected.Add('BloodChem' + #9 + '16' + #9 + 'Blood Chem'); to my app.  This was the only time in the last 10 years that I had to create a table and grid programmatically.  Please excuse my lack of knowledge in this area!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk