如何按下datagridview1中的链接并转到另一表格?

时间:2019-02-03 12:47:06

标签: c# mysql datagridview

如何在数据网格中按链接并转到另一种形式?

enter image description here

代码:

foreach (DataRow item in ds.Tables["timeentryrangedetails"].Rows)
        {
            DataGridViewLinkColumn link = new DataGridViewLinkColumn();             
            dataGridView1.Columns.Add(link);
            int n = dataGridView1.Rows.Add();
            link.Text = "Details";
            link.UseColumnTextForLinkValue = true;
            dataGridView1.Rows[n].Cells[0].Value = link.Text;
            dataGridView1.Rows[n].Cells[1].Value = item["CutoffID"].ToString();
            dataGridView1.Rows[n].Cells[2].Value = item["StartDate"].ToString();
            dataGridView1.Rows[n].Cells[3].Value = item["EndDate"].ToString();
            dataGridView1.Rows[n].Cells[4].Value = item["withTax"].ToString();
            dataGridView1.Rows[n].Cells[5].Value = item["SSS"].ToString();
            dataGridView1.Rows[n].Cells[6].Value = item["PhilHealth"].ToString();
            dataGridView1.Rows[n].Cells[7].Value = item["Pagibig"].ToString();
            dataGridView1.Rows[n].Cells[8].Value = item["status"].ToString();
        }

1 个答案:

答案 0 :(得分:0)

您可以使用DataGridViewLinkColumn。

有关更多信息,read it