procedure TForm1.FormShow(Sender: TObject);
begin
adotable1.Open;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
adotable1.Close;
end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if DBGrid1.DataSource.DataSet.RecNo mod 2 = 0 then //条件判断
begin
with DBGrid1 do
begin
Canvas.Font.Color:=clRed;
Canvas.Brush.Color:=clYellow;
end;
end;
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
for I := Low(Names) to High(Names) do
begin
ListItem := Items.Add;
ListItem.Caption := Names[I][0];
ListItem.SubItems.Add(Names[I][1]);
end;
end;
end;
procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
if ListView1.ViewStyle = vsReport then
begin
if Odd(Item.Index) then
Listview1.Canvas.Brush.Color := $EEFFEE
else
ListView1.Canvas.Brush.Color:=$00E9FAFC;
end;