树递归绑定
2015-10-25 19:13:48 访问(1814) 赞(0) 踩(0)
/// <summary>
///
/// </summary>
const string application_cascade = "application_cascade";
/// <summary>
///
/// </summary>
const string application_form = "application_form";
/// <summary>
///
/// </summary>
/// <returns></returns>
public ImageList CreateTreeIconImageList()
{
ImageList theResult = new ImageList();
int idx = -1;
theResult.Images.Add
(
global::SlowX.WebManage.Properties.Resources.application_cascade
);
++idx;
theResult.Images.SetKeyName(idx, application_cascade);
theResult.Images.Add
(
global::SlowX.WebManage.Properties.Resources.application_form
);
++idx;
theResult.Images.SetKeyName(idx, application_form);
return theResult;
}
ImageList il = CreateTreeIconImageList();
treeView_Menu.ImageList = il;
/// <summary>
///
/// </summary>
/// <param name="mList"></param>
protected void InitMenuTree(List<WebClientMenuDataInfo> mList)
{
TreeView tv = treeView_Menu;
tv.Nodes.Clear();
DataBindTree
(
tv.Nodes,
mList,
0
);
}
/// <summary>
///
/// </summary>
/// <param name="tnc"></param>
/// <param name="mList"></param>
/// <param name="pId"></param>
protected void DataBindTree
(
TreeNodeCollection tnc,
List<WebClientMenuDataInfo> mList,
long pId
)
{
TreeNode tn = null;
foreach (WebClientMenuDataInfo info in mList)
{
if (info.PID != pId)
{
continue;
}
tn = new TreeNode();
tn.Name = CommonName.tn_ + info.ID.ToString();
tn.Tag = info;
tn.Text = info.TheName;
if (info.ToolTip != null && info.ToolTip.Length > 0)
tn.ToolTipText = info.ToolTip;
if (info.ClassName != null && info.ClassName.Length > 0)
{
tn.ImageKey
=
application_form;
tn.SelectedImageKey
=
application_form;
}
else
{
tn.ImageKey
=
application_cascade;
tn.SelectedImageKey
=
application_cascade;
}
tnc.Add(tn);
DataBindTree
(
tn.Nodes,
mList,
info.ID
);
}
}
标签:
树递归绑定 


上一条:
下一条:
相关评论
发表评论