Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 34 total
Thread Grid Row varying height and hiding border lines
Thu, Sep 10 2015 6:49 PMPermanent Link

Trinione

Hi:
I am using the Grid component to build Calendar like functionality and need to be able to do 2 things:

(1) How can the height of every other Row on the grid be set to say a value of 20.

So,
Row 1 height = 20
Row 2 height = 50
Row 3 height = 20
Row 4 height = 50
Row 5 height = 20
Row 6 height = 50
.. and so on

and

(2) How can I disable / set Cell borders and their colors?

Thanks.
Thu, Sep 10 2015 11:41 PMPermanent Link

Trinione

Since I am pretty sure this will help others working on manual Grids, this is what I have done thus far.

To change the height of the row/cell.

procedure TForm1.Button1Click(Sender: TObject);
var
 i: integer;
 col: TGridColumn;           
 cel: TGridCell;

begin                             
 for i := 0 to 1 do
 begin
   col := Grid1.NewColumn;

   if i=0 then
   begin
     col.OnCellUpdate := GridColumn1CellUpdate;
     col.width := 60;
   end;

 end;

 for i := 0 to 2 do  // create two blank rows
 begin
   Grid1.AppendRow;
 end;            

 Grid1.Rows[0][1] := 'Row 2';
end;


procedure TForm1.GridColumn2CellUpdate(Sender: TObject; ACell: TGridCell);
begin
 if ACell.Index = 0 then
 begin
   ACell.Font.Size := 10;
   ACell.Height := 20;
 end;

 if ACell.Index = 1 then
   ACell.Background.Fill.Color:=clElevateRed;
end;
Fri, Sep 11 2015 9:30 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< (1) How can the height of every other Row on the grid be set to say a value of 20.  >>

You can do this in a cell update, like you found, but it won't be accounted for properly in the grid updates.  In other words, the rows won't fit in the grid properly unless the total height of all of the rows adds up the same as that specified by the RowHeight property.

<< (2) How can I disable / set Cell borders and their colors? >>

This you *can* do in the OnCellUpdate event handler for the applicable grid column.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Sep 11 2015 5:54 PMPermanent Link

Trinione

<<<< (2) How can I disable / set Cell borders and their colors? >>>>

<<This you *can* do in the OnCellUpdate event handler for the applicable grid column. >>

Tim:
Oooooookaaaay... Thanks for the Cliffhanger. Now, how can I do it? Smile
Fri, Sep 11 2015 5:57 PMPermanent Link

Trinione

<<<< (1) How can the height of every other Row on the grid be set to say a value of 20.  >>>>

<<You can do this in a cell update, like you found, but it won't be accounted for properly in the grid updates.  In other words, the rows won't fit in the grid properly unless the total height of all of the rows adds up the same as that specified by the RowHeight property. >>

Ah! That explains the mysterious disappearing/reappearing on scroll act I got.

Could a solution by to have a Hidden Row that makes up the difference for the total height then? Hmmmm... going and see if that works.
Sat, Sep 12 2015 7:32 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Oooooookaaaay... Thanks for the Cliffhanger. Now, how can I do it? Smile>>

Never mind - I forgot that the Border property isn't surfaced for the cells, and you wouldn't be able to set it anyways because it can be overridden by ShowLines changes.

Tim Young
Elevate Software
www.elevatesoft.com
Sat, Sep 12 2015 7:32 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Could a solution by to have a Hidden Row that makes up the difference for the total height then? Hmmmm... going and see if that works. >>

Honestly, I wouldn't try to do this right now and just wait until there is proper support for variable-height rows in the grid controls.

Tim Young
Elevate Software
www.elevatesoft.com
Sun, Sep 13 2015 3:32 AMPermanent Link

Trinione

Tim:
I was able to create a lovely Calendar that works perfectly for my needs.

Variable row heights would be a fantastic grid feature. Also, maybe properties for the border, but for this project I am able to live without, but I can certainly see its usefullness.

Here is the pertinent code:

col.OnCellUpdate := GridColumn1CellUpdate;


procedure TForm1.GridColumn1CellUpdate(Sender: TObject; ACell: TGridCell);
begin
 SetupCells(ACell);
end;

procedure TForm1.SetupCells(ACell: TGridCell);
begin
 if (ACell.Index mod 2) = 0 then
 begin
   ACell.Font.Size := 12;
   ACell.Font.Color := clElevateGray;
   ACell.Background.Fill.Color := clWhite;
 end
 else
 begin
     ACell.Font.Size := 16;
     ACell.Background.Fill.Color:=clWhiteSmoke;
     ACell.Background.Clip := otClient;
   //end;
 end;
end;



Attachments: myEWBCal.png
Sun, Sep 13 2015 6:29 AMPermanent Link

Uli Becker

> I was able to create a lovely Calendar that works perfectly for my needs.

Just to be sure: you are aware of the new calendar control introduced
with the latest build?

Uli
Sun, Sep 13 2015 11:38 AMPermanent Link

Trinione

Uli Becker wrote:

> I was able to create a lovely Calendar that works perfectly for my needs.

<< Just to be sure: you are aware of the new calendar control introduced
with the latest build? >>

Uli:
Yes I am aware of the new calendar controls.

However, I need a 'calendar' feature that gets and sets data, so I created one manually with the grid.
Page 1 of 4Next Page »
Jump to Page:  1 2 3 4
Image