TreeView控件的属性

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TreeView控件的属性相关的知识,希望对你有一定的参考价值。

参考技术A

DropHighlight属性(ListView, TreeView控件),
Indentation属性,
LabelEdit属性,
LineStyle属性,
Nodes属性,
PathSeparator属性(TreeView控件),
SelectedItem属性(ActiveX控件),
Sorted属性(TreeView控件),
Style属性(TreeView控件),
Checkboxes属性,
FullRowSelect属性,
Scroll属性,
SingleSel属性,
HotTracking属性,
TabIndex属性,
Tag属性,
Visible属性,
DragIcon属性,
DragMode属性,
CausesValidation属性,
MouseIcon属性,
TabStop属性,
HelpContextID属性,
Name属性,
Parent属性,
Container属性,
ToolTipText属性,
WhatsThisHelpID属性,
OLEDragMode属性(ActiveX控件),
OLEDropMode属性(ActiveX控件),
Height , Width属性(ActiveX控件),
Index属性(ActiveX控件),
Left, Top属性(ActiveX控件),
Object属性(ActiveX控件),
Appearance属性(ActiveX控件),
BorderStyle属性(ActiveX控件),
Enable属性(ActiveX控件),
Font属性(ActiveX控件),
HideSelection属性(ActiveX控件),
hWnd属性(ActiveX控件),
MousePointer属性(ActiveX控件),
ImageList属性(ActiveX控件)。

Winform中TreeView的常用属性和方法?

详细。有事例更好。

TreeView控件是APS.NET中的常用控件,现对其用法做一简单小结,具体内容如下:

1.public TreeNode FindNode(string valuePath) ... 其中valuePath指节点的值路径 示例代码如下:

/// <summary>
/// 填充左侧的模块树
/// </summary>
/// <param name="tv_modules">树形控件</param>
/// <param name="selectedMID">选中的模块组号</param>
public void BuildLeftTree(TreeView tv_modules, int selectedMID)

//添加根节点
TreeNode rootTN = new TreeNode();
rootTN.Text = SysConfig.LEFTTREE_ROOT_TEXT;
rootTN.Value = SysConfig.LEFTTREE_ROOT_VALUE;
rootTN.ImageUrl = SysConfig.LEFTTREE_ROOT_IMAGEURL;
rootTN.NavigateUrl = SysConfig.LEFTTREE_ROOT_NAVIGATEURL;
rootTN.Target = SysConfig.LEFTTREE_ROOT_TARGET;
rootTN.PopulateOnDemand = false;
rootTN.SelectAction = TreeNodeSelectAction.None;
rootTN.Expand();
tv_modules.Nodes.Add(rootTN);

PlatformAccessor pa = new PlatformAccessor();

DataSet ds = pa.getCodeRow(6, 1);
DataTable dt = ds.Tables[0];
DataRow dr = dt.Rows[0];

string content = dr["CONTENTS"].ToString();

XmlNodeList nodes = _xmldoc.SelectNodes("/Root/MyModules/Item");

if (content == "1")

//添加“我的模块”节点
TreeNode mymodulesTN = new TreeNode();
mymodulesTN.Text = SysConfig.LEFTTREE_MYMODULES_TEXT;
mymodulesTN.Value = SysConfig.LEFTTREE_MYMODULES_VALUE;
mymodulesTN.ImageUrl = SysConfig.LEFTTREE_MYMODULES_IMAGEURL;
mymodulesTN.NavigateUrl = SysConfig.LEFTTREE_MYMODULES_NAVIGATEURL;
mymodulesTN.Target = SysConfig.LEFTTREE_MYMODULES_TARGET;
mymodulesTN.PopulateOnDemand = false;
mymodulesTN.SelectAction = TreeNodeSelectAction.None;
mymodulesTN.Expand();
rootTN.ChildNodes.Add(mymodulesTN);

//添加“我的模块”
foreach (XmlNode xmlnode in nodes)

_addOneTreeNode(mymodulesTN, xmlnode, false);




PlatformAccessor pfa = new PlatformAccessor();

DataRow row = pfa.getModuleData(selectedMID);

int mlevel = int.Parse(row["MLEVEL"].ToString());
int mtopid = int.Parse(row["MTOPID"].ToString());

if (mlevel == 1 && mtopid == -1)

XmlNodeList rootList = _xmldoc.SelectNodes("/Root/Item");

foreach (XmlNode xn in rootList)

_addOneTreeNode(rootTN, xn, false, selectedMID);


return;

else

int mid = selectedMID;

int[] mids = new int[mlevel];

for (int i = 0; i < mlevel; i++)

DataRow dr_Temp = pfa.getModuleData(mid);

mids[i] = int.Parse(dr_Temp["MID"].ToString());

mid = int.Parse(dr_Temp["MTOPID"].ToString());


int[] sort_mids = new int[mlevel];

for (int i = 0; i < mlevel; i++)

sort_mids[i] = mids[mlevel - 1 - i];


for (int i = 0; i < mlevel; i++)

if (i == 0)

XmlNodeList rootList = _xmldoc.SelectNodes("/Root/Item");

foreach (XmlNode xn in rootList)

_addOneTreeNode(rootTN, xn, false, sort_mids[i]);


else

string temp = "";

for (int k = 0; k < (i + 1); k++)

temp += "/" + sort_mids[k].ToString();


//string valuePath = "ROOT/1031/1036";

string valuePath = SysConfig.LEFTTREE_ROOT_VALUE + temp;

TreeNode treeNode = tv_modules.FindNode(valuePath);

treeNode.Expand();






参考技术A 请参见 仔细看对你以后有用
http://msdn.microsoft.com/zh-cn/library/system.windows.forms.treeview_members.aspx

以上是关于TreeView控件的属性的主要内容,如果未能解决你的问题,请参考以下文章

treeview控件使用详解

delphi中的treeview控件如何取到选择节点的索引号?

WPF 之 TreeView节点重命名

C# winform treeview 节点展开状态的图标设置

asp.net控件treeview如何实现无刷新效果

C#动态给treeview控件添加节点和子节点