在DBGrid中显示诸如CheckBox等控件(50分)

  • 主题发起人 主题发起人 xself
  • 开始时间 开始时间
X

xself

Unregistered / Unconfirmed
GUEST, unregistred user!
在DBGrid中显示诸如CheckBox等控件
 
建议你用其他的GRID控件如INFOPOWER中带的DBGRID。
如不想用第三方的控件用DBGRID也可实现
请检查邮箱
 
给你一段代码:
procedure TFrmExchOption.DBGrid1DrawDataCell(Sender: TObject;
const Rect: TRect; Field: TField; State: TGridDrawState);
begin

if (gdFocused in State) then

if (Field.FieldName = DBComboBox1.DataField) then
begin
DBComboBox1.Left := Rect.Left + DBGrid1.Left;
DBComboBox1.Top := Rect.Top + DBGrid1.top+panel2.Top;
DBComboBox1.Width := Rect.Right - Rect.Left+4;
DBComboBox1.Visible := True;
end
end;

procedure TFrmExchOption.DBGrid1ColExit(Sender: TObject);
begin
if DBGrid1.SelectedField.FieldName = DBComboBox1.DataField then
DBComboBox1.Visible := false;

end;

procedure TFrmExchOption.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
//当DBComboBox1在cell中时,在cell中输入的键传给DBComboBox1
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;
 
接受答案了.
 
后退
顶部