想用grid显示记录,然后让用户在checkbox选择记录. 用TlistView吧TlistView.checkboxes:=true;就可以 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在GRID中加checkbox:unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grids;type TForm1 = class(TForm) grid: TStringGrid; procedure FormCreate(Sender: TObject); procedure gridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); procedure gridClick(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; fcheck,fnocheck:tbitmap;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);var i:SmallInt; bmp:TBitmap;begin FCheck:= TBitmap.Create; FNoCheck:= TBitmap.Create; bmp:= TBitmap.create; try bmp.handle := LoadBitmap( 0, PChar(OBM_CHECKBOXES )); With FNoCheck Do Begin width := bmp.width div 4; height := bmp.height div 3; canvas.copyrect( canvas.cliprect, bmp.canvas, canvas.cliprect ); End; With FCheck Do Begin width := bmp.width div 4; height := bmp.height div 3; canvas.copyrect( canvas.cliprect, bmp.canvas, rect( width, 0, 2*width, height )); End; finally bmp.free end;end;procedure TForm1.gridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);begin if not (gdFixed in State) then with TStringGrid(Sender).Canvas do begin brush.Color:=clWindow; FillRect(Rect); if Grid.Cells[ACol,ARow]='yes' then Draw( (rect.right + rect.left - FCheck.width) div 2, (rect.bottom + rect.top - FCheck.height) div 2, FCheck ) else Draw( (rect.right + rect.left - FCheck.width) div 2, (rect.bottom + rect.top - FCheck.height) div 2, FNoCheck ); end;end;procedure TForm1.gridClick(Sender: TObject);begin if grid.Cells[grid.col,grid.row]='yes' then grid.Cells[grid.col,grid.row]:='no' else grid.Cells[grid.col,grid.row]:='yes';end;end. Merry Christmas 安装上Raize 4.0之后[Error] RzCommon.pas(6376): Undeclared identifier: 'clMenuBar' 用delphi7对excel文件表进行处理的问题~~ 自定义消息 关于使用多程线连接应用服务的问题,大家帮帮忙 请高手进入-(关于输入法切换时,程序会停止响应) 那边有delphi 6下载的呢, 三层结构应用服务器的调试 两台机如何共享上网(都是win98)? DecodeDate把date数据字段分开,反过来的那个函数叫什么名字? dll中函数引用问题,帮帮忙 怎样将图片插入数据库呀?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids;type
TForm1 = class(TForm)
grid: TStringGrid;
procedure FormCreate(Sender: TObject);
procedure gridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure gridClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
fcheck,fnocheck:tbitmap;
implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
var
i:SmallInt;
bmp:TBitmap;
begin
FCheck:= TBitmap.Create;
FNoCheck:= TBitmap.Create;
bmp:= TBitmap.create;
try
bmp.handle := LoadBitmap( 0, PChar(OBM_CHECKBOXES ));
With FNoCheck Do Begin
width := bmp.width div 4;
height := bmp.height div 3;
canvas.copyrect( canvas.cliprect, bmp.canvas, canvas.cliprect );
End;
With FCheck Do Begin
width := bmp.width div 4;
height := bmp.height div 3;
canvas.copyrect(
canvas.cliprect,
bmp.canvas,
rect( width, 0, 2*width, height ));
End;
finally
bmp.free
end;
end;
procedure TForm1.gridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if not (gdFixed in State) then
with TStringGrid(Sender).Canvas do
begin
brush.Color:=clWindow;
FillRect(Rect);
if Grid.Cells[ACol,ARow]='yes' then
Draw( (rect.right + rect.left - FCheck.width) div 2,
(rect.bottom + rect.top - FCheck.height) div 2,
FCheck )
else
Draw( (rect.right + rect.left - FCheck.width) div 2,
(rect.bottom + rect.top - FCheck.height) div 2,
FNoCheck );
end;
end;procedure TForm1.gridClick(Sender: TObject);
begin
if grid.Cells[grid.col,grid.row]='yes' then
grid.Cells[grid.col,grid.row]:='no'
else
grid.Cells[grid.col,grid.row]:='yes';
end;end.