Home > Back-end >  Questions about TDBGridEh! Please comment.
Questions about TDBGridEh! Please comment.

Time:09-16

The Columns in the following process for DBGridEh1 OnEditButtonClick [I] button click event,

Procedure TAForm. DBGridEh1Columns4EditButtonClick (Sender: TObject; Var Handled: Boolean);
Var
The begin

Sender I think through the process object to obtain belongs in current DBGrideh1 Columns [I] column column number of the object,
Don't know in what way? Please grant instruction! Thank you very much!

end;

CodePudding user response:

In the event of DBGridEh, as long as into the Column: TColumnEh parameters, through the Column. The Index, know which Column,

CodePudding user response:

reference 1st floor lyhoo163 response:
in the event of DBGridEh, as long as into the Column: TColumnEh parameters, through the Column. The Index, to know how many columns,


Can you specifically?

Procedure TAForm. DBGridEh1Columns4EditButtonClick (Sender: TObject; Var Handled: Boolean);
Var
The begin
In the process of the Sender is not a TColumnEh type of object,
I use the showmessage (sender. The className) checked the it is a TEditButtonControlEh types of parameters, in ToolCtrlsEh unit had defined,
Specific how to write also please grant instruction! Thank you,

end;

CodePudding user response:

Sender can be cast to TDBGridColumnEh,
To get a field name in the column, for example, can:
Procedure TForm1. DBGridEh1Columns0EditButtonClick (Sender: TObject;
Var Handled: Boolean);
The begin
ShowMessage ((Sender as TDBGridColumnEh). FieldName);
end;

CodePudding user response:

reference npkaida reply: 3/f
Sender can be cast to TDBGridColumnEh,
To get a field name in the column, for example, can:
Procedure TForm1. DBGridEh1Columns0EditButtonClick (Sender: TObject;
Var Handled: Boolean);
The begin
ShowMessage ((Sender as TDBGridColumnEh). FieldName);
end;


As you can write an error "Invalid class typecast." "

CodePudding user response:

Directly with the Grid OnEditButtonClick Event, through the Grid. SelectIndex can obtain the current Column, if you want to deal with in this Event to avoid the Grid DefaultAction, remember to the Column. EditButton. DefaultAction set to False.

CodePudding user response:

 
Procedure TForm1. DBGridEh1Columns4EditButtonClick (Sender: TObject; Var Handled: Boolean);
Var
ColNo: Integer;
The begin
ColNo:=(TDBGridEh (TEditButtonControlEh (Sender). The Owner. The Owner). The Col);
ShowMessage (IntToStr (ColNo));//column 1 shows 1, column 2 shows 2, and so on...
end;

CodePudding user response:

 
Procedure TForm1. DBGridEh1Columns0EditButtonClick (Sender: TObject;
Var Handled: Boolean);
Var
ColNo: Integer;
The begin
//ColNo:=(TDBGridEh (TEditButtonControlEh (Sender). The Owner. The Owner). The Col);
ColNo:=(TDBGridEh (TEditButtonControlEh (Sender). The Parent, the Parent, the Parent). The Col);
ShowMessage (IntToStr (ColNo));//column 1 shows 1, column 2 shows 2, and so on...
end;

CodePudding user response:

It is ok to like this:
 procedure TMDI_1_1_Frm. DBGridEh1EditButtonClick (Sender: TObject); 
Var ColNo: Integer;
The begin
ColNo:=TDBGridEh (Sender). The Columns. The Grid. The Col.
ShowMessage (IntToStr (ColNo));
end;

CodePudding user response:

 
The type of the Sender is TEditButtonControlEh
Inheritance and TDBGridEh class is:
TDBGridEh & lt; - TCustomDBGridEh & lt; - TCustomDBAxisGridEh & lt; - TCustomGridEh & lt; -
TCustomControlEh & lt; - TCustomControl & lt; - TWinControl & lt; - TControl & lt; -
TComponent & lt; - TPersistent & lt; - TObject
That is to say, a subclass of TDBGridEh not TEditButtonControlEh
Thus TDBGridEh (Sender) this kind of transformation is certainly not
  • Related