J
jianguo_bu
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGridEh, DB, ADODB, LMDCustomControl, LMDCustomPanel,
LMDCustomBevelPanel, LMDBaseEdit, LMDCustomEdit, LMDEdit;
type
TForm1 = class(TForm)
DBGridEh1: TDBGridEh;
DataSource1: TDataSource;
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
ADODataSet1code: TIntegerField;
ADODataSet1name: TWideStringField;
ADODataSet1name1: TWideStringField;
LMDEdit1: TLMDEdit;
ADODataSet1sdate: TDateTimeField;
DBGrid1: TDBGrid;
procedure DBGridEh1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure DBGridEh1ColExit(Sender: TObject);
procedure DBGridEh1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.DBGridEh1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if (gdFocused in State) then
begin
if (Field.FieldName = 'name' ) then
begin
LMDEdit1.Left := Rect.Left + DBGridEh1.Left;
LMDEdit1.Top := Rect.Top + DBGridEh1.top;
LMDEdit1.Width := Rect.Right - Rect.Left;
LMDEdit1.Height := Rect.Bottom - Rect.Top;
LMDEdit1.Visible := True;
end;
end;
end;
procedure TForm1.DBGridEh1ColExit(Sender: TObject);
begin
If DBGridEh1.SelectedField.FieldName = 'name' then
begin
LMDEdit1.Visible := false;
end;
end;
procedure TForm1.DBGridEh1KeyPress(Sender: TObject; var Key: Char);
begin
if (key <> chr(9)) then
begin
if (DBGridEh1.SelectedField.FieldName ='name') then
begin
LMDEdit1.SetFocus;
SendMessage(LMDEdit1.Handle, WM_Char, word(Key), 0);
end;
end;
DBGridEh1.Columns[0]
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGridEh, DB, ADODB, LMDCustomControl, LMDCustomPanel,
LMDCustomBevelPanel, LMDBaseEdit, LMDCustomEdit, LMDEdit;
type
TForm1 = class(TForm)
DBGridEh1: TDBGridEh;
DataSource1: TDataSource;
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
ADODataSet1code: TIntegerField;
ADODataSet1name: TWideStringField;
ADODataSet1name1: TWideStringField;
LMDEdit1: TLMDEdit;
ADODataSet1sdate: TDateTimeField;
DBGrid1: TDBGrid;
procedure DBGridEh1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure DBGridEh1ColExit(Sender: TObject);
procedure DBGridEh1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.DBGridEh1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if (gdFocused in State) then
begin
if (Field.FieldName = 'name' ) then
begin
LMDEdit1.Left := Rect.Left + DBGridEh1.Left;
LMDEdit1.Top := Rect.Top + DBGridEh1.top;
LMDEdit1.Width := Rect.Right - Rect.Left;
LMDEdit1.Height := Rect.Bottom - Rect.Top;
LMDEdit1.Visible := True;
end;
end;
end;
procedure TForm1.DBGridEh1ColExit(Sender: TObject);
begin
If DBGridEh1.SelectedField.FieldName = 'name' then
begin
LMDEdit1.Visible := false;
end;
end;
procedure TForm1.DBGridEh1KeyPress(Sender: TObject; var Key: Char);
begin
if (key <> chr(9)) then
begin
if (DBGridEh1.SelectedField.FieldName ='name') then
begin
LMDEdit1.SetFocus;
SendMessage(LMDEdit1.Handle, WM_Char, word(Key), 0);
end;
end;
DBGridEh1.Columns[0]
end;
end.