如题
解决方案 »
- Delphi 导出的数字字符串如何不加单引号且不成为科学计数法?
- access 自定义函数
- 如果判断wwDBGrid的已经选择了记录?
- Active的在Type Library的问题
- 怎么样在richedit中做查找
- 共享修改问题
- delphi2005中TIdUDPServer接收问题
- 急!!!我希望DBGrid实现ListView列表显示时的checkbox功能,我只是希望选种我需要的数据,不希望因此而在表中加个bool字段,请问大侠怎
- Unable to terminiate the process????
- 求:群发短消息
- 高手请进来,关于打印的问题。在线求助!!快,有高分啊!
- 面对C++,JAVA的强烈攻势,Delph路在何方!
add field,新建一个字段,里面可以设置。
add field,新建一个字段,里面可以设置。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, Grids, DBGrids, DB, DBTables;type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBComboBox1: TDBComboBox;
DBComboBox2: TDBComboBox;
DBComboBox3: TDBComboBox;
procedure DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure DBGrid1ColExit(Sender: TObject);
procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if (gdFocused in State) then
begin
if (Field.FieldName = DBCombobox1.DataField) then
begin
DBCombobox1.Left :=Rect.Left + DBgrid1.Left;
DBCombobox1.Top := Rect.Top + DBgrid1.Top;
DBCombobox1.Width := Rect.Right - Rect.Left;
DBCombobox1.Visible :=True;
end;
if (Field.FieldName = DBCombobox2.DataField) then
begin
DBCombobox2.Left :=Rect.Left + DBgrid1.Left;
DBCombobox2.Top := Rect.Top + DBgrid1.Top;
DBCombobox2.Width := Rect.Right - Rect.Left;
DBCombobox2.Visible :=True;
end; if (Field.FieldName = DBCombobox3.DataField) then
begin
DBCombobox3.Left :=Rect.Left + DBgrid1.Left;
DBCombobox3.Top := Rect.Top + DBgrid1.Top;
DBCombobox3.Width := Rect.Right - Rect.Left;
DBCombobox3.Visible :=True;
end;
end;
end;procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
if DBGrid1.SelectedField.FieldName = DBCombobox1.DataField then
begin
DBCombobox1.Visible := false;
end;
if DBGrid1.SelectedField.FieldName = DBCombobox2.DataField then
begin
DBCombobox2.Visible := false;
end;
if DBGrid1.SelectedField.FieldName = DBCombobox3.DataField then
begin
DBCombobox3.Visible := false;
end;
end;procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if (key <> chr(9)) then
begin
if (DBGrid1.SelectedField.FieldName = DBCombobox1.DataField ) then
begin
DBCombobox1.SetFocus;
SendMessage(DBCombobox1.Handle,WM_CHAR,word(Key),0);
end; if (DBGrid1.SelectedField.FieldName = DBCombobox2.DataField ) then
begin
DBCombobox2.SetFocus;
SendMessage(DBCombobox1.Handle,WM_CHAR,word(Key),0);
end; if (DBGrid1.SelectedField.FieldName = DBCombobox3.DataField ) then
begin
DBCombobox3.SetFocus;
SendMessage(DBCombobox1.Handle,WM_CHAR,word(Key),0);
end;
end;
end;end.
这是在DBGrid放一个DBComboBox的例子,你可以改改就好了。
To:debussy(debussy) 如果我要有30 个X 2000行 这么多的checkbox 那效率会不会太低?
还有没有简单的方法?
要做得像ACCESS 表里面那个勾,该怎么搞呢?
在Tquery字段编辑器中直接赋字段的displayvalues的值即可;
用下面这个值即可:
√;×
这样可以实现动态变化吗?我说的意思是能不能实现点一下则变化一回的功能啊?