我想通过DrawCell事件调用颜色对话框,通过鼠标点击列,弹出颜色对话框,该列显示选择color,同时在程序中调用选择的color.若是有其他好的办法也可以指点。谢谢!
达到目的就结贴给分!
达到目的就结贴给分!
解决方案 »
- dbgrideh过滤怎么设置
- DELPHI写的程序已经编译好
- 怎么实现image1图像的淡入淡出
- 如何判断本机上是否安装了BDE,以及BDE的版本号。
- +++++高分求助!我在一个线程里使用showmessage('end!');怎么出错啦?大家帮我看看代码!谢谢!
- 在dbgrid里的options属性里,有一个dgediting,我怎么在程序中动态地给他改变值?
- 分太多,分大家点
- reportmachine操作手册
- 如何用flash控件连续播放动画?
- DELPHI和拨号连接?(我是入门菜鸟)
- 高手进!基于WebService访问远程数据库程序的问题!在线等!
- 将一个表的数据复制到另一个表的问题!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, DB, ADODB, Grids;type
TForm1 = class(TForm)
Button1: TButton;
StringGrid1: TStringGrid;
ColorDialog1: TColorDialog;
procedure StringGrid1Click(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
private
{ Private declarations }
currRow,currcol :integer;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.StringGrid1Click(Sender: TObject);
var
i :integer;
tempStr :string;
StrHeight :integer;
Rect: TRect;
begin
if currRow=1 then
begin
if ColorDialog1.Execute then
begin
for i :=0 to StringGrid1.RowCount-1 do
begin
tempStr:=stringgrid1.Cells[currcol,i];
Rect :=StringGrid1.CellRect(currcol,i);
with stringgrid1.Canvas do
begin
StrHeight:=TextHeight(tempStr);
Brush.Color:=ColorDialog1.Color ;
FillRect(Rect);
Rectangle(Rect);
TextOut(Rect.Left+2,Rect.Top+(Rect.Bottom-Rect.Top-StrHeight) div 2,tempStr);
end;
end;
end;
end;
end;procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
currRow := ARow;
currcol :=ACol;
end;end.