如何讓TreeView.Item 反白 |
尚未結案
|
p786939
一般會員 發表:2 回覆:9 積分:2 註冊:2002-11-12 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
FYI, create a CustomDrawItem for the treeview.
procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); begin if Node.Level>0 then with Sender.Canvas do begin Brush.Color := clYellow; FillRect(Node.DisplayRect(True)); end; end; |
p786939
一般會員 發表:2 回覆:9 積分:2 註冊:2002-11-12 發送簡訊給我 |
謝謝,如果要讓它 UnEnabled 如何設定.
引言: FYI, create a CustomDrawItem for the treeview.procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); begin if Node.Level>0 then with Sender.Canvas do begin Brush.Color := clYellow; FillRect(Node.DisplayRect(True)); end; end; |
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
p786939
一般會員 發表:2 回覆:9 積分:2 註冊:2002-11-12 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
p786939
一般會員 發表:2 回覆:9 積分:2 註冊:2002-11-12 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
To draw text in disabled color:
procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); var ARect: TRect; begin if Node.Level>0 then with Sender.Canvas do begin ARect := Node.DisplayRect(True); Font.Color := clGrayText; TextRect(ARect,ARect.Left 1,ARect.Top 1,Node.Text); end; end; procedure TForm1.TreeView1Editing(Sender: TObject; Node: TTreeNode; var AllowEdit: Boolean); begin AllowEdit := (Node.Level=0); end;You may need to create a 'disabled' image on the fly for drawing and it is not a trivial task. You may also want to handle the OnExpanding and OnCollapsing events to make the nodes look like really disabled. |
p786939
一般會員 發表:2 回覆:9 積分:2 註冊:2002-11-12 發送簡訊給我 |
謝謝,我的Item 如何指定'disabled' image ,請指教.
引言: To draw text in disabled color:procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); var ARect: TRect; begin if Node.Level>0 then with Sender.Canvas do begin ARect := Node.DisplayRect(True); Font.Color := clGrayText; TextRect(ARect,ARect.Left 1,ARect.Top 1,Node.Text); end; end; procedure TForm1.TreeView1Editing(Sender: TObject; Node: TTreeNode; var AllowEdit: Boolean); begin AllowEdit := (Node.Level=0); end;You may need to create a 'disabled' image on the fly for drawing and it is not a trivial task. You may also want to handle the OnExpanding and OnCollapsing events to make the nodes look like really disabled. |
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
p786939
一般會員 發表:2 回覆:9 積分:2 註冊:2002-11-12 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |