Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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"


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

Please help.
Don.
Posted
Updated 21-Dec-10 17:57pm
v2
Comments
Dr.Walt Fair, PE 21-Dec-10 21:34pm    
So, what is DGV(2,1 ) supposed to refer to?

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))

Here DGV(2, 1).Style.Font.Style is nothing when you show this value in quick watch.
 
Share this answer
 
v2
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?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900