开发者

underline in datagridview

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

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

开发者_JAVA百科

thanks.


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.


You should set the style as:

dgv.Columns[5].DefaultCellStyle.Font = New Font(dgv.DefaultCellStyle.Font, FontStyle.Underline)


I think you should do it for each row. For example: For Each r As DataGridViewRow In dgv.Rows r.Cells(5).Style.Font = New Font(dgv.DefaultCellStyle.Font, FontStyle.Underline) Next


If you are using C#, use this.

dataGridView1.Columns[0].DefaultCellStyle.Font = new Font(dataGridView1.DefaultCellStyle.Font, FontStyle.Underline);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜