Stano 143 Posted March 28, 2023 There is no problem at column 0. I'm addressing the other ones. I found this on the internet. I don't understand the code, but it works. There is one problem. It is ugly at the moment. Is there a solution where it will be prettier? I just need to display it! I don't like the use of the image. A1. Draw a CheckBox and start drawing in OnAfterCellPaint. Here you can see the styles in Winapi.Windows, not only the CheckBox, but also the RadioButton. uses Winapi.Windows; procedure TfrmFilterCust.vstAfterCellPaint(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; CellRect: TRect); var vANode: PCustNode; begin if Column = 3 then begin vANode := Sender.GetNodeData(Node); if vANode.IsCustomer then DrawFrameControl(TargetCanvas.Handle, CellRect, DFC_BUTTON, DFCS_CHECKED) else DrawFrameControl(TargetCanvas.Handle, CellRect, DFC_BUTTON, DFCS_BUTTONCHECK); end else if Column = 4 then begin vANode := Sender.GetNodeData(Node); if vANode.IsSupplier then DrawFrameControl(TargetCanvas.Handle, CellRect, DFC_BUTTON, DFCS_CHECKED) else DrawFrameControl(TargetCanvas.Handle, CellRect, DFC_BUTTON, DFCS_BUTTONCHECK); end; end; A2. Click on CheckBox to select the Node using the OnMouseDown mouse. procedure TfrmFilterCust.vstMouseDown(Sender: TObject; Button: TMouseButton; procedure TfrmFilterCust.vstMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin FSeledNode := vst.GetNodeAt(X, Y); end; Edit the material properties in the OnColumnClick event and redraw the RepaintNode in the call. procedure TfrmFilterCust.vstColumnClick(Sender: TBaseVirtualTree; Column: TColumnIndex; Shift: TShiftState); var vANode: PCustNode; begin if Column = 3 then begin vANode := Sender.GetNodeData(FSeledNode); vANode.IsCustomer := not vANode.IsCustomer; Sender.RepaintNode(FSeledNode); end else if Column = 4 then begin vANode := Sender.GetNodeData(FSeledNode); vANode.IsSupplier := not vANode.IsSupplier; Sender.RepaintNode(FSeledNode); end; end; This completes the display and editing of the CheckBox in the column. B. Check box in the header Edit header \ Columns \ Column[n] \ Set properties in properties: CheckBox = True , Show CheckBox. CheckType = ctCheckBox, typ je CheckBox a RadioButton CheckState = csUncheckedNormal //csCheckedNormal to see if there is a check In the properties, edit the header\Options check itShowImages in the properties edit TreeOptions\MiscOptions check to checkSupport Share this post Link to post
dwrbudr 8 Posted March 28, 2023 Inspect VirtualTrees.pas code and especially procedure TBaseVirtualTree.PaintCheckImage Share this post Link to post
Stano 143 Posted March 28, 2023 I'll look into it. I don't want to use images. Maybe the feature in question is about something else. I'll see. Share this post Link to post