tags:

views:

17

answers:

2

hello,

I want to underline all items in one column. My code does not work.

dgv.Columns(5).DefaultCellStyle.Font.Underline()

thanks.

+1  A: 

You weren't doing anything with it in your code sample. You have to assign it a value if you want to change it.

dgv.Columns(5).DefaultCellStyle.Font.Underline = True

David Stratton
@Jay Riggs - thank you. I copied his code and just added the "= True". I missed that.
David Stratton
A: 

Are you setting that property before or after inserting a value into the cell? I am not 100% sure, but, if memory serves, this will not change the style retroactively.

Looking at http://msdn.microsoft.com/en-us/library/system.drawing.font_members.aspx, it seems that Underline() is just a property that tells you if it's underlined. In C#, you might do

dgv.Columns(5).DefaultCellStyle.Font = new Font(dgv.Columns(5).DefaultCellStyle.Font, FontStyle.Underline);

but I don't know the VB syntax offhand.

Jonathan