找一个带checkbox的treeview 控件(300分)

  • 主题发起人 主题发起人 htw
  • 开始时间 开始时间
H

htw

Unregistered / Unconfirmed
GUEST, unregistred user!
找一个带checkbox的treeview 控件
谢谢了!
 
免费加源代码,性能优越
Virtual Treeview
http://www.delphi-gems.com/VirtualTreeview/VT.php
 
兄弟分给我吧:代码如下
unit CheckTreeview;

interface

uses
Windows, Messages, SysUtils, Classes, Controls,Commctrl,ComCtrls;
const
TVIS_CHECKED = $2000;
type
TCheckTreeview = class(TTreeView)
private
{ Private declarations }
protected
{ Protected declarations }
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
function IsChecked(Node :TTreeNode) :Boolean;
procedure SetChecked(Node :TTreeNode; Checked :Boolean);
published
{ Published declarations }
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('syz_component', [TCheckTreeview]);
end;

{ TCheckTreeview }

procedure TCheckTreeview.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style:=Params.Style or TVS_CHECKBOXES;
end;

function TCheckTreeview.IsChecked(Node: TTreeNode): Boolean;
var
TvItem :TTVItem;
begin
TvItem.Mask := TVIF_STATE;
TvItem.hItem := Node.ItemId;
TreeView_GetItem(Node.TreeView.Handle, TvItem);
Result := (TvItem.State and TVIS_CHECKED) = TVIS_CHECKED;
end;

procedure TCheckTreeview.SetChecked(Node: TTreeNode; Checked: Boolean);
var
TvItem :TTVItem;
begin
FillChar(TvItem, SizeOf(TvItem), 0);
with TvItem do begin
hItem := Node.ItemId;
Mask := TVIF_STATE;
StateMask := TVIS_STATEIMAGEMASK;
if Checked then
TvItem.State :=TVIS_CHECKED
else
TvItem.State :=TVIS_CHECKED shr 1;
TreeView_SetItem(Node.TreeView.Handle, TvItem);
end;
end;
end.
 
系统中就有,如果没有装一下 VB 6.0 肯定有!!
导入系统的就行了
选择菜单"Component","Import ActiveX control"
然后选 “Microsoft common controls 6.0(sp4)(version 2.0)”

其中有多个好用的控件。
 
我要的是vcl控件
 
Virtual Treeview
 
只需要在创建树时加一句话
node.CheckboxType := (tvctNone,tvctcheckbox,tvctRadioGroup);

node1 := fctreeview1.Items.Add(nil, fieldbyname('name').AsString);
node1.CheckboxType := (tvctRadioGroup);//这是加单选框
 
多人接受答案了。
 
后退
顶部