【问题标题】:Not able to display Text in ObjectViewList TreeView无法在 ObjectViewList TreeView 中显示文本
【发布时间】:2021-08-20 21:48:51
【问题描述】:

我正在使用 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;
     }

关于我做错了什么有什么想法吗?

【问题讨论】:

    标签: c# objectlistview treelistview


    【解决方案1】:

    这实际上是脑死愚蠢的简单,我没有密切关注演示。您所要做的就是设置要显示的属性。

     this.objectName.AspectName = "Text";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-08
      • 1970-01-01
      • 1970-01-01
      • 2017-10-03
      • 2018-08-14
      • 2016-01-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多