Delphi How to use the DelphiVCL.DrawGrid.Col

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009
How to use the DelphiVCL.DrawGrid.Col
By Muhammad Azizul Hakim June 14, 2021

DelphiVCL.DrawGrid.Col specifies the index of the column that contains the selected cell.

Use DelphiVCL.DrawGrid.Col at runtime to determine the current column in the grid. Setting Col moves focus to the cell in the current row that is in the new column. The first column has an index of 0, the second column an index of 1, and so on.

The selected cell in the grid can be located by reading the Col property and the Row property to obtain the indexes of its column and row. When focus moves to the grid, the selected cell gets input focus.
Let’s browse all the properties, methods, and built-in properties of the DelphiVCL.DrawGrid.Col using dir() command:
Python:
import DelphiVCL
 
dir(DelphiVCL.DrawGrid.Col)
See the responses in our Windows command prompt:
1623753367521.png
Here is the working example of the implementation of DelphiVCL.DrawGrid.Col:
Python:
def grdTestDrawCell(Sender, Col, Row, Rect, State):
    if gdSelected in State:
        Sender.Canvas.Brush.Color = clBlue # 0x00ff0000 # blue
        Sender.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, "%d @ %d" % (Col, Row))
 
def grdTestSelectCell(Sender, Col, Row, CanSelect):
    if Col == 2 and Row == 2:
        CanSelect.Value = False
 
grdTest.OnDrawCell = grdTestDrawCell
grdTest.OnSelectCell = grdTestSelectCell
See the complete code Для просмотра ссылки Войди или Зарегистрируйся.

The result:
1623753397819.png
1623753402991.png