C# Winforms DataGridViewLinkColumn 动态去除下划线
C# Winforms DataGridViewLinkColumn remove underline dynamically
我有一个 DataGridView,其中一列的类型为 DataGridViewLinkColumn。我需要根据某些条件从该列下所有行的文本中删除下划线。我怎样才能在代码中动态地做到这一点?
请建议我一些解决方法。谢谢!
试试这个,根据你的情况修改...
foreach (DataGridViewRow row in dataGridView1.Rows)
{
foreach (var cell in row.Cells)
{
DataGridViewLinkCell linkCell = cell as DataGridViewLinkCell;
if(linkCell != null)
{
linkCell.LinkBehavior = LinkBehavior.NeverUnderline;
}
}
}
我有一个 DataGridView,其中一列的类型为 DataGridViewLinkColumn。我需要根据某些条件从该列下所有行的文本中删除下划线。我怎样才能在代码中动态地做到这一点?
请建议我一些解决方法。谢谢!
试试这个,根据你的情况修改...
foreach (DataGridViewRow row in dataGridView1.Rows)
{
foreach (var cell in row.Cells)
{
DataGridViewLinkCell linkCell = cell as DataGridViewLinkCell;
if(linkCell != null)
{
linkCell.LinkBehavior = LinkBehavior.NeverUnderline;
}
}
}