dataGridView中添加超链接操作


 首先在dataGridView里面添加datagridviewlinkcolumn列

  然后选择dataGridView的CellContentClick事件:

   如下:

              private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2)
            {
               
                System.Diagnostics.Process.Start("iexplore.exe", "http://social.microsoft.com/Forums/zh-CN/2212/threads");
     //this.dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());

            }
        }

 

  在绑定中可以设置在dataGridView中显示的文本,即text属性即可,然后在单击事件中System.Diagnostics.Process.Start,传入的网址也是根据此行的相关数据得到,

可以用以下方法获取    

              ds.Tables[0].Rows[e.RowIndex]["ID"].ToString()

  这样但点击此链接的时候就会出现相关的网页。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM