Board index » delphi » Sender (Again)

Sender (Again)

This is a real basic question but since I'm working on a database with a
grid, I'll ask it here.

In DBGrid1ColEnter (The default ColEnter routine) I want to check and see
what the current field is in the grid. I tried using Sender.Fname and
Sender.FieldName to no avail. (see example code)

procedure TForm1.DBGrid1ColEnter(Sender: TObject);
begin
  edit1.text := Sender.Name;
end;

Where edit1 is an Tedit object.

Can someone explain how I can get this info?

Thanks,

Cal Evans

 

Re:Sender (Again)


use the TDBGrid.SelectedField property

Ryan Peterson
rpete...@usit.net

In article <4afons$...@grouper.Exis.Net>, KEv...@exis.net (Kathy Evans) says:

Quote
>In DBGrid1ColEnter (The default ColEnter routine) I want to check and see
>what the current field is in the grid. I tried using Sender.Fname and
>Sender.FieldName to no avail.

Re:Sender (Again)


In article <4afons$...@grouper.Exis.Net>, KEv...@exis.net (Kathy Evans) says:

Quote

>This is a real basic question but since I'm working on a database with a
>grid, I'll ask it here.

>In DBGrid1ColEnter (The default ColEnter routine) I want to check and see
>what the current field is in the grid. I tried using Sender.Fname and
>Sender.FieldName to no avail. (see example code)

>procedure TForm1.DBGrid1ColEnter(Sender: TObject);
>begin
>  edit1.text := Sender.Name;
>end;

>Where edit1 is an Tedit object.

Try this: I use it all the time:

Procedure TForm1.DBGrid1ColEnter(Sender: TObject);
begin
  with DBGrid1 do
   begin
    if SelectedField.Name = 'Table1FieldName' then   {Fieldname}
      .....
   end;
end;

Hope this helps
Jose R. Nebro
jo...@dorsai.org

Re:Sender (Again)


If I clearly understand, it is simple:

Edit1.Text := DBGrid1.SelectedField.FieldName;

Nenad

Other Threads