简体   繁体   English

C#Winforms DataGridViewLinkColumn动态删除下划线

[英]C# Winforms DataGridViewLinkColumn remove underline dynamically

I have a DataGridView with one of the columns of type DataGridViewLinkColumn. 我有一个带有DataGridViewLinkColumn类型的列之一的DataGridView。 I need to remove the underline from the text of all the rows under that column on certain criteria. 我需要根据某些条件从该列下所有行的文本中删除下划线。 How can I do that Dynamically in the code? 如何在代码中动态地做到这一点?

Please suggest me some workarounds. 请建议我一些解决方法。 Thanks! 谢谢!

Try this, modify according to your cases... 试试这个,根据您的情况进行修改...

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM