Dear programmers, I wanted to ask: is it possible to constantly allocate the string treeview, whether the focus is independently transferred to this component or not?
2 answers
The choice of color is yours
procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); begin if cdsSelected in State then begin Sender.Canvas.Font.Color := clWindow; Sender.Canvas.Brush.Color := clGreen; end else begin Sender.Canvas.Font.Color := clWindow; Sender.Canvas.Brush.Color := clRed; end; end;
- @praddos is awesome! Brilliant and simple at the same time! Thank you so much! :) - Aleksandr
- @Alexander , not at all, contact - Praddos
- @praddos, I apologize for the intrusiveness, but I would like to know, but can you do the same for TListBox? Unfortunately there is no CustomDrawItem event. - Alexander
- @Alexander, there on the ListBox1DrawItem event (Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState) try - Praddos
- @praddos Thank you for your advice :) - Aleksandr
|
Selecting an item in the TreeView without losing the selected item when the focus is lost))
with TreeView1 do begin SetFocus; Selected := Items[1]; HideSelection :=False; //без этого выделяет, но при потере фокуса выделенный элемент становится, как все остальные)) end;
- I agree with this, but if you lose the focus, the selection is lost, and is it possible to save it? - Aleksandr
- add TreeView1.HideSelection: = False; and the selection will not be lost - NMD
- it works, but it becomes so light gray, and it is possible to leave it blue, as per the standard? Or is it even possible to change the color? - Александр
- possible, but I do not know how - NMD
- Well - I will look, thank you very much :) - Aleksandr
|