我正在使用 ObjectViewList TreeListView 并按照示例进行操作,但没有显示文本。TreeListView 确实填充了,您可以看到可以展开的节点,并且它们确实以正确数量的子节点展开,但文本不显示。
下面是代码:
private void SetupTree(TreeNode objectRoot)
{
this.treeObjectView.CanExpandGetter = delegate (object x) {
return ((TreeNode)x).Nodes.Count > 0;
};
this.treeObjectView.ChildrenGetter = delegate (object x) {
try
{
return ((TreeNode)x).Nodes;
}
catch (UnauthorizedAccessException ex)
{
this.BeginInvoke((MethodInvoker)delegate () {
this.treeObjectView.Collapse(x);
MessageBox.Show(this, ex.Message, "ObjectListViewDemo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
});
return new ArrayList();
}
};
ArrayList roots = new ArrayList();
foreach (TreeNode di in objectRoot.Nodes)
{
roots.Add(di);
}
this.treeObjectView.Roots = roots;
}
这是设计器代码:
{
//
// treeObjectView
//
this.treeObjectView.AllColumns.Add(this.objectName);
this.treeObjectView.CellEditUseWholeCell = false;
this.treeObjectView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.objectName});
this.treeObjectView.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeObjectView.HideSelection = false;
this.treeObjectView.Location = new System.Drawing.Point(3, 3);
this.treeObjectView.Name = "treeObjectView";
this.treeObjectView.ShowGroups = false;
this.treeObjectView.Size = new System.Drawing.Size(533, 589);
this.treeObjectView.TabIndex = 3;
this.treeObjectView.UseCompatibleStateImageBehavior = false;
this.treeObjectView.View = System.Windows.Forms.View.Details;
this.treeObjectView.VirtualMode = true;
//
// objectName
//
this.objectName.MinimumWidth = 200;
this.objectName.Text = "Text";
this.objectName.ToolTipText = "Object Name";
this.objectName.Width = 200;
}
关于我做错了什么的任何想法?