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...
精彩评论