如何在Windows窗体上的datagridview上向现有文本附加红色* [英] How do I append a red * to existing text on a datagridview on windows form
本文介绍了如何在Windows窗体上的datagridview上向现有文本附加红色*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在运行时期间无法在网格视图的绑定数据文本的末尾附加红色*
我尝试了什么:
尝试添加一个带有两个不同标签的用户控件,其中第一个包含实际网格单元数据,第二个包含红色*。但是,在运行期间无法用用户控件替换网格单元格的文本。
解决方案
唯一的方法是处理DataGridView.CellPainting Event(System.Windows.Forms) [< a href =https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellpainting(v=vs.110).aspx\"target =_ blanktitle =New Window > ^ ]并自己绘制文本的两个部分。
这可能有助于一些结构,但你需要使用Graphics.DrawString方法(System.Drawing) [ ^ ]两次绘制文本和你的星星。
Not able to append a red * at the end of a text of a bound data on a grid view during runtime.
What I have tried:
Tried to add a user control with two different label on which first one contains actual grid cell data and second one contains red *. However, not able to replace grid cell's text with user control during runtime.
解决方案
The only way to do that is you handle the DataGridView.CellPainting Event (System.Windows.Forms)[^] and draw both parts of the text yourself.
This may help with some of the structure, but you'll need to use Graphics.DrawString Method (System.Drawing)[^] twice to draw the text and your star.
这篇关于如何在Windows窗体上的datagridview上向现有文本附加红色*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文