Hi there,
Below is my code to merge cells (2 by 2) on a TStringGrid.
The problem is that the merging operation occurs on the first row (which is Fixed) and the 3d aspect of the cell doesn't fit. That is, there's still a line draw in the middle of the 2 cells (light 3d color) which is supposed to be left aligned. The text section is ok, prb is only 3d rectangle.
|------------------------|
| |----------||
| | ||
| |----------||
|------------------------|
instead of
|------------------------|
||----------------------||
|| ||
||----------------------||
|------------------------|
---------------------------------------------------------
procedure Grid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
ColRect: TRect;
sInfo: String;
begin
if (ARow = 0) then
with Grid1, Grid1.Canvas do
begin
if (ACol > 0) and (ACol mod 2 = 0) then
begin
ColRect := CellRect(ACol-1, 0);
Rect.Left := ColRect.Left;
FillRect(Rect);
TextRect(Rect, Rect.Left+(Rect.Right-
Rect.Left) div 2 - TextWidth(Cells[ACol-1, ARow])
div 2, Rect.Top+2, Cells[ACol-
1, ARow]);
end;
end;
end;
---------------------------------------------------------
Thank you all
Below is my code to merge cells (2 by 2) on a TStringGrid.
The problem is that the merging operation occurs on the first row (which is Fixed) and the 3d aspect of the cell doesn't fit. That is, there's still a line draw in the middle of the 2 cells (light 3d color) which is supposed to be left aligned. The text section is ok, prb is only 3d rectangle.
|------------------------|
| |----------||
| | ||
| |----------||
|------------------------|
instead of
|------------------------|
||----------------------||
|| ||
||----------------------||
|------------------------|
---------------------------------------------------------
procedure Grid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
ColRect: TRect;
sInfo: String;
begin
if (ARow = 0) then
with Grid1, Grid1.Canvas do
begin
if (ACol > 0) and (ACol mod 2 = 0) then
begin
ColRect := CellRect(ACol-1, 0);
Rect.Left := ColRect.Left;
FillRect(Rect);
TextRect(Rect, Rect.Left+(Rect.Right-
Rect.Left) div 2 - TextWidth(Cells[ACol-1, ARow])
div 2, Rect.Top+2, Cells[ACol-
1, ARow]);
end;
end;
end;
---------------------------------------------------------
Thank you all