setFocus in the grid column with the name of the field in the database

Asked

Viewed 352 times

0

When I try to focus on a specific column by the name of the field in the database, it is not right.

However if I do putting the number in the order of the column, example column 4, I know, but I wanted to name the field.

I wished it that way, but so it does not give the focus:

if condicao then
  grdAjuste.SetFocus('id_codigo');

Now if I do so, it works properly:

if condicao then
  grdAjuste.SetFocus(4);

But I think that last form is not very correct.

How could I properly focus on the field through its name?

1 answer

1

You can do it this way

grdAjuste.SelectedField := cdsDados.FieldByName('id_codigo');
  • thanks partner

Browser other questions tagged

You are not signed in. Login or sign up in order to post.