我创建个树形结构,但是怎么就显示不出来子节点!
代码如下publicpartialclassForm1:Form{privateTreeViewtreeview;publicForm1(){InitializeComp...
代码如下 public partial class Form1 : Form
{
private TreeView treeview;
public Form1()
{
InitializeComponent();
create();
}
public void create()
{
TreeNode fNode = new TreeNode("aa");
DevExpress.XtraNavBar.NavBarGroup nbGroup = navBarControl1.Groups.Add();
treeview = new TreeView();
nbGroup.Caption = fNode.Text.ToString();
nbGroup.GroupStyle = DevExpress.XtraNavBar.NavBarGroupStyle.ControlContainer;
treeview.DrawMode = TreeViewDrawMode.Normal;
TreeBindding( fNode);
treeview.ItemHeight = 20;
treeview.Parent = nbGroup.ControlContainer;
}
private void TreeBindding(TreeNode fNode)
{
List<TreeNode> listGN2 = new List<TreeNode>()
{
new TreeNode("AA"),
new TreeNode("BB"),
new TreeNode("CC"),
new TreeNode("DD"),
};
for (int j = 0; j < listGN2.Count; j++)
{
fNode.Nodes.Add(listGN2[j]);
}
我已经改好了this.navBarControl1.Controls.Add(treeview) 展开
{
private TreeView treeview;
public Form1()
{
InitializeComponent();
create();
}
public void create()
{
TreeNode fNode = new TreeNode("aa");
DevExpress.XtraNavBar.NavBarGroup nbGroup = navBarControl1.Groups.Add();
treeview = new TreeView();
nbGroup.Caption = fNode.Text.ToString();
nbGroup.GroupStyle = DevExpress.XtraNavBar.NavBarGroupStyle.ControlContainer;
treeview.DrawMode = TreeViewDrawMode.Normal;
TreeBindding( fNode);
treeview.ItemHeight = 20;
treeview.Parent = nbGroup.ControlContainer;
}
private void TreeBindding(TreeNode fNode)
{
List<TreeNode> listGN2 = new List<TreeNode>()
{
new TreeNode("AA"),
new TreeNode("BB"),
new TreeNode("CC"),
new TreeNode("DD"),
};
for (int j = 0; j < listGN2.Count; j++)
{
fNode.Nodes.Add(listGN2[j]);
}
我已经改好了this.navBarControl1.Controls.Add(treeview) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询