大哥小弟们:有没有能方便地编辑MEMO字段的DBGRID组件?在线等待!!!(100分)

  • 主题发起人 主题发起人 千层雪
  • 开始时间 开始时间
先放一个DBMemo1,初始化visible:=False;
procedure TYanxinForm.DBGrid1DrawDataCell(Sender: TObject;
const Rect: TRect;
Field: TField;
State: TGridDrawState);
begin
if not DBMemo1.Focused then
DBMemo1.Visible :=False;
//加这么一句,左右移动,包括调整列宽时都没有问题了
if (gdFocused in State) or (gdSelected in State) then
if Field.Datatype = ftMemo then
begin
DBMemo1.DataField :=Field.FieldName;
DBMemo1.Left := Rect.Left + DBGrid1.Left;
DBMemo1.Top := Rect.Top + DBGrid1.top;
DBMemo1.Width :=Rect.Right - Rect.Left;
DBMemo1.Height :=DBMemo1.Width;
DBMemo1.Visible := True;
end;
end;

procedure TYanxinForm.DBGrid1ColExit(Sender: TObject);
begin
If DBGrid1.SelectedField.FieldName = DBMemo1.DataField then
DBMemo1.Visible := false;
end;

procedure TYanxinForm.DBGrid1KeyPress(Sender: TObject;
var Key: Char);
begin
if (key <> chr(9)) then
begin
if (DBGrid1.SelectedField.FieldName = DBMemo1.DataField) then
begin
DBMemo1.SetFocus;
SendMessage(DBMemo1.Handle, WM_Char, word(Key), 0);
end
else
begin
if Key=Char(VK_RETURN) then
begin
SendMessage(DBGrid1.Handle,WM_KEYDOWN, VK_DOWN,0);
Key:=Char(0);
end;
end;
end;

end;
 
DevExpress TdxGrid下载:
http://www.8421.org/download.php?id=133
 
接受了。
 
多人接受答案了。
 
谢谢QDYANG提供的下载地址,我的还是去年留下来的,昨天我在网上找了好久都没有找到新版的下载
 
后退
顶部