Board index » delphi » GridWidth on the fly

GridWidth on the fly

I am attempting to compute the actual grid width needed for all the columns so that a horizontal scroll bar is not needed and does not appear;

this is what I have been trying but it doesn't seem to work

grid.width := 0;
for i:=0 to (gird.rowcount - 1) do
begin
    grid.width := grid.width + gird.colwidths[i] + 1 //  the one is for  the  grid divider I have tryed various values but nothing seems to be consistent.
end;

suggestions?

Marci

 

Re:GridWidth on the fly


Shouldn't that be something like

var
   AColWidth: Integer;
   I: Integer;
begin
   AColWidth := Grid.Width div Grid.ColCount;
   for I := 0 to Grid.ColCount - 1 do
     Grid.ColWidths[I] := AColWidth;
end;

You don't set the columnwidth in your code, you set the grid width. As I
understand
from your question your are trying to resize the columns no?
Also I don't understand why you use rowcount?

Quote
>I am attempting to compute the actual grid width needed for all the columns

so that a horizontal scroll bar is not needed and >does not appear;

Re:GridWidth on the fly


On Wed, 24 Jan 2001 11:06:15 -0800, "Marci Wilken" <mar...@hlyw.com>
wrote:

Quote
>I am attempting to compute the actual grid width needed for all the =
>columns so that a horizontal scroll bar is not needed and does not =
>appear;

>this is what I have been trying but it doesn't seem to work

Try something like

var x, y: Integer;
begin
  x:= GetSystemMetrics(SM_CXVSCROLL) + 3;
  for y:= 0 to Grid.ColCount-1 do begin
     x:= x + Grid.ColWidths[y];
  end;
  x:= x + Grid.ColCount * Grid.GridLineWidth;
  Grid.ClientWidth:= x;

Quote
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
><HTML><HEAD>

Marci, please post only plain text messages into Borland newsgroups
http://www.borland.com/newsgroups/netiquette.html
http://www.borland.com/newsgroups/guide.html

HTH
ain

Other Threads