Put a TCheckBox inside a TStringGrid in Delphi

前端 未结 3 1443
猫巷女王i
猫巷女王i 2020-12-13 16:44

I want to put a TCheckBox inside a TStringGrid in Delphi in every cell of certain column. I\'m using Delphi XE.

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 16:54

    Don't try to place an actual TCheckBox control inside a TStringGrid. Use the grid's OnDrawCell event with the Win32 API DrawFrameControl() function instead, to draw an image of a CheckBox control inside each cell as needed. You can use the OnClick/OnMouse... events with the grid's Objects[][] property to keep track of each cell's checked state as needed. I find this is a lot easier to manage, since TStringGrid was not designed to host real controls.

提交回复
热议问题