在DataGridView中切换文本 [英] Toggle text in DataGridView

查看:100
本文介绍了在DataGridView中切换文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在网上拖了好几个小时了.我要做的就是在Regular和StrikeOut之间的未绑定DataGridView的单元格中切换文本.我一直在尝试这一行代码(以及其他代码):-

Hi, I have been trawling the net for hours. All I want to do is toggle text in a cell in an unbound DataGridView between Regular and StrikeOut. I have been trying with this line of code (amongst others):-

"If DGV(2, 1).Style.Font.Style = FontStyle.Strikeout Then"



我得到的答案是''object reference not set to an instance of an object''.

请帮忙.
唐.



The answer I get is ''object reference not set to an instance of an object''.

Please help.
Don.

推荐答案

唐,

像这样在datagridview中设置行的字体.
HI Don,

Set Font of row in a datagridview like this.
DGV(2, 1).Style.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Strikeout, System.Drawing.GraphicsUnit.Point, CType(0, Byte))


在快速监视中显示此值时,这里的DGV(2,1).Style.Font.Style无效.


Here DGV(2, 1).Style.Font.Style is nothing when you show this value in quick watch.


感谢您的答复,但我没有设置问题StrikeOut的字体.我的问题是确定字体是Regular还是StrikeOut-我需要在Regular和StrikeOut之间切换,所以我需要知道单元格中存在哪种字体.如何确定?
Thanks for the reply, but I don''t have a problem setting the font to StrikeOut. My problem is determining whether the font is Regular or StrikeOut - I need to toggle between Regular and StrikeOut so I need to know which exists in the cell. How do I determine that?


这篇关于在DataGridView中切换文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆