开发者

How to remove underline of specific link cells in DataGridView

开发者 https://www.devze.com 2023-03-21 03:03 出处:网络
Some columns of my datagridview are link columns. Based on data fetched I\'d like to set the LinkBehavior of certain cells to NeverUnderLine. Trouble is that I 开发者_运维问答can iterate only through

Some columns of my datagridview are link columns. Based on data fetched I'd like to set the LinkBehavior of certain cells to NeverUnderLine. Trouble is that I 开发者_运维问答can iterate only through DataGridViewCell and not DataGridViewLinkCell. DataGridViewCell doesn't has the LinkBehavior property (which is quite logical).

So how exactly do I set the LinkBehavior property of a cell?

      foreach (DataGridViewCell dcell in dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells)
      {
        if (dcell.Value.ToString() == "Error")
        {
         dcell.Style.ApplyStyle(style);

         //dcell.LinkBehavior = LinkBehavior.NeverUnderline;

        }
      }


See if you can type cast your cell DataGridViewCell to a link cell DataGridViewLinkCell and change its properties.

DataGridViewLinkCell linkCell = dcell as DataGridViewLinkCell
if(linkCell != null)
//your code...
0

精彩评论

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