我在通知应用程序中使用 TreeView 。当我加载包含大量文本的节点时,文本被截断为 12 个字符。我该如何避免这种情况发生?
正在使用的字体: Microsoft Sans Serif, 12pt, style=Bold
我曾尝试使用纯字体,但没有成功。
这是我的代码(我用另一个类覆盖了树节点):
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);
}
}
最佳答案
将 TreeView 的字体大小属性值设置为高于您以编程方式设置的字体大小。
关于c# - Winforms Treeview 文本被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33288606/