Winform程序使用DataGridView做显示用,某列单元格中包含超链接。例如单元格内的值是:“该商品来源http://xxxx.xxx ”请教各位:单元格内如果有超链接地址,如何让该超链接地址显示为带下划线格式,字体颜色变为蓝色。
鼠标单击该超链接可以在默认浏览器中打开该URL地址。注:该单元格内其他非超链接文本保持原来的字体颜色和格式。谢谢DataGridView超链接URLC#

解决方案 »

  1.   

    链接列的DataGridView类型为 DataGridViewLinkColumn即可打开链接        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
            {
                if (e.ColumnIndex == 链接列号)
                {
                    System.Diagnostics.Process.Start("iexplore.exe", this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
                }
            }
      

  2.   

    加载时,先用正则判断是不是超链,是的话,在此列单元格加LinkLable显示超链。
    private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
            {
            if(.......)
    {
    加入LinkLable
    }
            }
      

  3.   

    非链接列的DataGridView类型 不用 DataGridViewLinkColumn即可