Yes, it would be if it is painted, but the first record has already been selected.
When I want to check it out I do this
if query.FieldByName(campo_id).AsInteger >= 1 then
// procedimento para realizar chamada de tela entre outros...
CAUTION !!
DBGDados.Columns.Grid.Focused
Check if the focus is on the grid !!
If you want to change the color of the selected line you have this code
if not odd(qyrBuscaBanco.RecNo) then // deixa grid zebrado
begin
if not (gdSelected in State) then
begin
dbgrdBanco.Canvas.Brush.Color := clMoneyGreen;
dbgrdBanco.Canvas.FillRect(Rect);
dbgrdBanco.DefaultDrawDataCell(rect,Column.Field,state);
end;
end;
with dbgrdBanco do // pinta a linha selecionada
begin
if DataSource.DataSet.State in [dsEdit, dsInsert, dsBrowse] then
begin
if (Rect.Top = TStringGrid(dbgrdBanco).CellRect( DataCol ,TStringGrid(dbgrdBanco).Row).Top)
or( gdSelected in State) then
begin
Canvas.FillRect(Rect);
Canvas.Brush.Color := [COR PARA A LINHA SELECIONADA];
DefaultDrawDataCell(Rect,Column.Field,State)
end;
end;
end;