【发布时间】:2015-10-22 18:56:34
【问题描述】:
我在通知应用程序中使用树视图。当我加载包含大量文本的节点时,文本被截断为 12 个字符。如何防止这种情况发生?
使用的字体: Microsoft 无衬线字体,12pt,样式=粗体
我尝试过使用普通字体,但没有成功。
这是我的代码(我已经用另一个类覆盖了树节点):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace Repetrel
{
public class ActionObjectTreeNode: TreeNode
{
public string fileName = null;
private ActionObject actionObject = new ActionObject();
public string Text {
get { return base.Text; }
set {
if (value.Equals(base.Text) == false && base.Text!="")
{
Trace.WriteLine("error detected");
}
base.Text = value;
}
}
public ActionObject ACTIONOBJECT
{
get
{
return actionObject;
}
set
{
actionObject = value;
if (value == null && TREENODETYPE != TreeNodeType.Project) {
System.Diagnostics.Trace.WriteLine("null assigned to actionobject");
}
}
}
public TreeNodeType TREENODETYPE { get; set; }
public TreeNodeType LOCKEDNODETYPE { get; set; }
public DrillActionGroup ACTIONPROPERTIES { get; set; }
public ActionObjectTreeNode()
{
}
public ActionObjectTreeNode(string text)
{
this.Text = text;
}
public ActionObjectTreeNode(ActionObject actionObject)
{
if (actionObject != null)
{
this.Text = actionObject.TEXT;
this.ACTIONOBJECT = actionObject;
}
}
public bool guidMatch(string _guid)
{
return ACTIONOBJECT.getGuid().Equals(_guid);
}
}
}
【问题讨论】:
-
最好把能重现问题的代码展示给我们。
-
代码没有重现问题。你是否压倒了其他任何东西?您应该会看到有关在覆盖 Text 属性中使用“new”关键字的警告。
-
@LarsTech - 现在完整代码。我没有使用 new 关键字。
-
this.Text = actionObject.TEXT;?我会在那条线上放一个调试器,看看那个值是什么。 -
@LarsTech - 没有调用该代码。我直接通过'Text'设置字符串,它被覆盖了。