源代码为:
procedure Tzccs.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;
end;end;procedure Tzccs.DBGrid1ColExit(Sender: TObject);
begin
If DBGrid1.SelectedField.FieldName
= DBComboBox1.DataField then
begin
DBComboBox1.Visible := false;
end;end;procedure Tzccs.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 + 25;
DBComboBox1.Width := Rect.Right - Rect.Left;
DBComboBox1.Height := Rect.Bottom - Rect.Top;
DBComboBox1.Visible := True;
end;
end;end;在dbgrid的columns editor中使用add all fields之后,可视控件就无法出现在dbgrid中.环境为win98 delphi7.0
procedure Tzccs.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;
end;end;procedure Tzccs.DBGrid1ColExit(Sender: TObject);
begin
If DBGrid1.SelectedField.FieldName
= DBComboBox1.DataField then
begin
DBComboBox1.Visible := false;
end;end;procedure Tzccs.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 + 25;
DBComboBox1.Width := Rect.Right - Rect.Left;
DBComboBox1.Height := Rect.Bottom - Rect.Top;
DBComboBox1.Visible := True;
end;
end;end;在dbgrid的columns editor中使用add all fields之后,可视控件就无法出现在dbgrid中.环境为win98 delphi7.0
解决方案 »
- DLL里FORM调用了CXGRID就报错
- 高手帮忙看一下,代码为什么会报错?
- 线程为什么过了一段时间就不执行了
- 高分求助!f(n)=f(n-1)+f(n-2)怎么 实现?扑克派开始发的程序如何实现,有UNIT文件最好
- 急,关于保存问题;(在线等待!!!!!)
- DELPHI如何产生按键的消息给特定的进程,或者给全部进程?
- Application.Terminate来终止程序,这样会不会造成内存不能被释放?欢迎讨论
- [新手]delphi里的IsNumeric只能带char,有没有检查一个字符串的?
- ADO+Access2000中的Blob字段最大字节数怎么设定呀
- 怎样在写com时加入动态数据的属性?急!!
- 关于D5的第三方控件在D6安装时出现的问题
- 急!!送分啦。。。16进制ASCII码转换成16进制数的问题?
begin
if (key<>chr(9)) then
begin
if (DBGrid1.SelectedField.FieldName=DBLookUPComboBox1.DataField) then
begin
DBLookupComboBox1.SetFocus;
SendMessage(DBLookupComboBox1.Handle,WM_Char, word(Key), 0);
end;
end;
end;
procedure TfrmInput.DBGrid1ColExit(Sender: TObject);
begin
if DBGrid1.SelectedField.FieldName== DBLookUpComboBox1.DataField then
DBLookupComboBox1.Visible := false;
end;
//****下面是与你不同的部分**********//
procedure TfrmInput.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if (gdFocused in State) and (Column.FieldName=DBLookUpcombobox1.Datafield) then
begin
//调整DBLookUpCombobox1的位置控制在Rect的范围内
DBLookupComboBox1.SetBounds(Rect.Left +DBGrid1.Left,
Rect.Top +DBGrid1.top,
Rect.Right-Rect.Left+2,
Rect.Bottom-Rect.Top-1
);
DBLookupComboBox1.Visible :=True;
end;end;