开发者

How to remove underline of specific link cells in DataGridView

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜