關於原版TreeView的使用

2022-09-17 08:30:09 字數 1271 閱讀 9535

view plain

copy to clipboard

print

?const

tvs_checkboxes = $00000100

;  procedure

tform1

.setcomctrlstyle(winctrl: twincontrol; value: integer; usestyle: boolean); 

varstyle: integer; 

begin

ifwinctrl

.handleallocated

then

begin

style := getwindowlong(winctrl.

handle, gwl_style); 

ifnot

usestyle

then

style := style and

notvalue 

else

style := style

orvalue; 

setwindowlong(winctrl.

handle, gwl_style, style); 

end; 

end; 

然後在form.create事件中呼叫即可:

view plain

copy to clipboard

print

?setcomctrlstyle(treeview1, tvs_checkboxes, true); 

另外,也可以把上述語句直接簡化成一句,只不過對於不熟悉api的人來說,可讀性是差了一些:

view plain

copy to clipboard

print

?setwindowlong(treeview1

.handle, gwl_style, getwindowlong(treeview1

.handle, gwl_style)

or$00000100

); 

經過這樣處理後的treeview就帶有了checkbox的效果,可是大家可能會發現,checkbox的下邊框線不見了。這是由於預設的node行距太小,可以對此進行修改。

(須要引用commctrl單元)

view plain

copy to clipboard

print

?treeview_setitemheight(treeview1

.handle,

20);  

關於原版TreeView的使用

原創 關於原版treeview的使用 d7中原版的treeview就很好用,但是卻沒有乙個屬性可以直接設定節點的checkbox,經過摸索,找到乙個較好的解決方案。view plain copy to clipboard print const tvs checkboxes 00000100 pro...

關於Treeview控制項的使用

昨日在在做專案的時刻用dhtmlx tree 做了乙個樹形的例項。覺得還挺好用的。今日覺得沒什麼事做。就想著用.net自帶的控制項去做一下樹。前台 後台 using system using system.collections.generic using system.linq using sys...

關於TreeView中CheckBox的使用

專案設計中要使用treeview中checkbox 在treeview的屬性中的checkboxes設為ture 想達到乙個這樣的效果 1 選中乙個節點,則子節點的狀態為當前節點的狀態並設定展開或摺疊。如 本來預設全部是摺疊的,當選擇laboratory並使其checked為true時,其子節點的狀...