L
lxl1227
Unregistered / Unconfirmed
GUEST, unregistred user!
stringgrid设置为gorowselect为TRUE,然后代码如下:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (ACol >0) and (ARow mod 2 = 0)and (ARow <> 0) then
begin
StringGrid1.Canvas.Font.Color:= clBlack;
StringGrid1.Canvas.Font.Size:= 12;
StringGrid1.Canvas.Brush.Color:= clRed;
StringGrid1.Canvas.FillRect(Rect);
StringGrid1.Canvas.TextOut(Rect.Left,Rect.Top,StringGrid1.Cells[ACol,ARow]);
end;
if (ACol >0) and (ARow mod 2 <> 0)and (ARow <> 0) then
begin
StringGrid1.Canvas.Font.Color:= clBlack;
StringGrid1.Canvas.Font.Size:= 12;
StringGrid1.Canvas.Brush.Color:= clAqua;
StringGrid1.Canvas.FillRect(Rect);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:Integer;
begin
with StringGrid1 do
begin
for i:=0 to RowCount-1 do
for j:=0 to ColCount-1 do
Cells[i+1,j+1]:='123';
end;
end;
为什么stringgrid重画后为什么选中整行的那个兰色条带框变成虚框了?怎么样才能恢复选中整行有兰色条带框呢?
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (ACol >0) and (ARow mod 2 = 0)and (ARow <> 0) then
begin
StringGrid1.Canvas.Font.Color:= clBlack;
StringGrid1.Canvas.Font.Size:= 12;
StringGrid1.Canvas.Brush.Color:= clRed;
StringGrid1.Canvas.FillRect(Rect);
StringGrid1.Canvas.TextOut(Rect.Left,Rect.Top,StringGrid1.Cells[ACol,ARow]);
end;
if (ACol >0) and (ARow mod 2 <> 0)and (ARow <> 0) then
begin
StringGrid1.Canvas.Font.Color:= clBlack;
StringGrid1.Canvas.Font.Size:= 12;
StringGrid1.Canvas.Brush.Color:= clAqua;
StringGrid1.Canvas.FillRect(Rect);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:Integer;
begin
with StringGrid1 do
begin
for i:=0 to RowCount-1 do
for j:=0 to ColCount-1 do
Cells[i+1,j+1]:='123';
end;
end;
为什么stringgrid重画后为什么选中整行的那个兰色条带框变成虚框了?怎么样才能恢复选中整行有兰色条带框呢?