社区
Delphi
帖子详情
关于stringGrid的疑问
肥仔胧
2004-08-30 09:06:26
请问如何在stringGrid重实现打勾,也就是说,我想在其某列上实现一个Boolean型的列
类似于checkBox的功能;(非dbgrid)
...全文
186
9
打赏
收藏
关于stringGrid的疑问
请问如何在stringGrid重实现打勾,也就是说,我想在其某列上实现一个Boolean型的列 类似于checkBox的功能;(非dbgrid)
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
9 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
eagle_2
2004-08-31
打赏
举报
回复
stringgrid中嵌套一个checkbox控件不就得了,还能得到很多属性和事件呢
checkbox1.left:=stringgrid1.cellrect[].left;
checkbox1.top:=stringgrid1.cellrect[].top;
checkbox1.height:=stringgrid1.cellrect[].height;
checkbox1.width:=stringgrid1.cellrect[].width;
再在每次重绘时记得:checkbox1.caption:=stringgrid1.cells[]一下
eagle_2
2004-08-31
打赏
举报
回复
stringgrid中嵌套一个checkbox控件不就得了,还能得到很多属性和事件呢
checkbox1.left:=stringgrid1.cellrect[].left;
checkbox1.top:=stringgrid1.cellrect[].top;
checkbox1.height:=stringgrid1.cellrect[].height;
checkbox1.width:=stringgrid1.cellrect[].width;
梅青松
2004-08-30
打赏
举报
回复
用两个图片:一个打勾,一个不打勾
将图片画在stringgrid 中
在onclick事件中切换两个图片即可
肥仔胧
2004-08-30
打赏
举报
回复
应该来说说话啊
有不同的方法,大家拿来相互学习嘛
rcaicc
2004-08-30
打赏
举报
回复
学习。。。。
capoatguitar
2004-08-30
打赏
举报
回复
溜达溜达不说话
luke5678
2004-08-30
打赏
举报
回复
unit Unit1;
interface
uses
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.
wofan
2004-08-30
打赏
举报
回复
郁闷个啥
在COL(0)里面打勾不就得
肥仔胧
2004-08-30
打赏
举报
回复
心情极度郁闷
关于
string
grid
写的一个小程序,操作
string
grid
的.
delphi
String
Grid
功能程序
实现了使用
String
Grid
各种功能的代码例子,比如嵌套日期控件,对它的 属性的灵活运用等!
String
Grid
实例 单元格变色等
String
Grid
实例 单元格变色等 学好DELPHI 就是学好这个控件 个人感觉
string
grid
多选拖拽换行
使用
string
grid
实现行多选, 然后通过拖拽移动选择行位置 按住ctrl可以多选不连续的行
string
grid
在进货单里怎样连续保存数据啊
Delphi
5,935
社区成员
262,943
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章