2017-05-04 204 views
0

我有一个DataGridView类型的DataGridViewLinkColumn列之一。我需要在特定条件下从该列下的所有行的文本中删除下划线。我该如何在代码中动态执行该操作?C#Winforms DataGridViewLinkColumn动态删除下划线

请给我一些解决方法。谢谢!

+0

有相反要求的旧问题。建议的解决方案也可能适用于您:https://stackoverflow.com/questions/16995775/how-to-make-datagridviewlinkcolumn-underline-and-change-background-color –

回答

1

试试这个,请根据您的情况......

foreach (DataGridViewRow row in dataGridView1.Rows) 
{ 
     foreach (var cell in row.Cells) 
     { 
     DataGridViewLinkCell linkCell = cell as DataGridViewLinkCell; 
     if(linkCell != null) 
     { 
      linkCell.LinkBehavior = LinkBehavior.NeverUnderline; 
     } 
     } 
}