如何使字符串加粗 [英] How to make part of string Bold
本文介绍了如何使字符串加粗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨..
我们可以这样吗?
在子节点的treeView中,我正在分配字符串值,但是我必须以粗体格式显示部分字符串.这部分我必须制作粗体项目列表[i].值
Hi..
Can we do like this ?
In treeView for child node I am assigning string value but in that I have to display part of string in Bold format. This part I have to make bold- itemslist[i].Value
TreeNode tn = this.treeViewResult.Nodes.Add(nodeTitle);
for (int i = 0; i < itemslist.Count; i++)
{
tn.Nodes.Add("node",itemslist[i].Name+":"+itemslist[i].Value,index);
}
请帮帮我...
谢谢
-Dattatrya Moin
}
Please help me...
Thank you
-Dattatrya Moin
推荐答案
您不能通过分配字符串值来做到这一点:TreeView控件不支持节点字符串中的格式代码.
您可以做到,但是要复杂一点:您必须自己处理节点本身,方法是处理DrawNode事件并在处理程序中进行文本格式化. MSDN TreeView.DrawNode [
You can''t do it by assigning a string value: the TreeView control does not support format codes in node strings.
You can do it, but it is a little more complex: you have to draw the node itself yourself, by handling the DrawNode event and doing the text formatting in the handler. MSDN TreeView.DrawNode[^] - it does include a basic example, which changes the font.
TreeView本身不支持这种自定义.但是您可以将其TreeView.DrawMode
属性设置为OwnerDrawText
.
然后,您的TreeView将引发 DrawNode事件 [ ^ ]可以自己订阅和处理所有文本绘图.
这样,您可以让GDI +以所需的任何方式绘制文本( Graphics.DrawString()方法 [ ^ ])
TreeView itself does not support such customization. But you can set itsTreeView.DrawMode
property toOwnerDrawText
.
Your TreeView will then raise the DrawNode event[^] which you can subscribe to and handle all of the text drawing on your own.
That way you can have GDI+ draw text in whatever fashion you need (Graphics.DrawString() method[^])
这篇关于如何使字符串加粗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文