dbgrid move the focus to the specified row and

dbgrid is inherited from TCustomGrid down, it has the col and row attributes, but is protected and can not be accessed directly, to deal with it, it can be:

    TDrawGrid (DBGrid1) .Row: = row;
    TDrawGrid (DBGrid1) .col: = COL;
    dbgrid1.setfocus;
you can see the effects.

    1 This approach is definitely a problem, it will cause confusion inside the DBGrid, because DBGrid Unable to locate the current record, if it fills DBGrid read-only (read-only or will be out to some problems, such as the original only radio can now record emergence of multiple choice, etc., you can go try it), if DBGrid that can be edited can be a big problem, because the relationship between the current record, you change the data field is probably not what you imagine
    2 my usual solution is to the program will be changed (easily set col is safe, with no problem)

    Query1.first;
    TDrawGrid (DBGrid1) .col: = 1;
    dbgrid1.setfocus;

    This allows the focus to the first row of the first broomrape

Guess you like

Origin www.cnblogs.com/jijm123/p/11259973.html