C# 如何将datagridview列设置为linktype

C# 如何将datagridview列设置为linktype,c#,datagridview,C#,Datagridview,我正在提取数据并存储在datatable中,以便在datatgridview中显示它,如何使datatable的第二列visitdate从链接类型开始? 像这样的 DataGridViewLinkColumn linkcol = new DataGridViewLinkColumn(); this.dataGridViewVisits.Columns[1].DefaultCellStyle = linkcol; 下面是我在datagridview中显示数据的代码 cmd1 = new OleD

我正在提取数据并存储在datatable中,以便在datatgridview中显示它,如何使datatable的第二列
visitdate
链接类型开始
? 像这样的

DataGridViewLinkColumn linkcol = new DataGridViewLinkColumn();
this.dataGridViewVisits.Columns[1].DefaultCellStyle = linkcol;
下面是我在datagridview中显示数据的代码

cmd1 = new OleDbCommand("Select VisitNo,VisitDate,remark from Patient_Visit_Details WHERE Patient_ID=" + pid, con);
            dt = new DataTable();
            adp1 = new OleDbDataAdapter(cmd1);
            adp1.Fill(dt);
            this.dataGridViewVisits.DataSource = dt;
            DataGridViewLinkColumn linkcol = new DataGridViewLinkColumn();
你好,

您只需使用智能导航在GridView控件中创建超链接列,并设置如下所示的值…


谢谢你, Vishal Patel您好,

您只需使用智能导航在GridView控件中创建超链接列,并设置如下所示的值…


谢谢你,
Vishal Patel

在将DataTable(dt)设置为DataGridView的数据源后添加此代码

foreach (DataGridViewRow row in dataGridViewVisits.Rows)
            {
                DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
                linkCell.Value = row.Cells[1].Value;
                row.Cells[1] = linkCell;
            }

这肯定会奏效的……)

将DataTable(dt)设置为DataGridView的数据源后添加此代码

foreach (DataGridViewRow row in dataGridViewVisits.Rows)
            {
                DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
                linkCell.Value = row.Cells[1].Value;
                row.Cells[1] = linkCell;
            }

这肯定会奏效的……)

处理datagridView的
DataBindingComplete
事件,如下所示

  private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            foreach (DataGridViewRow r in dataGridView1.Rows)
            {
                r.Cells[1] = new DataGridViewLinkCell();
            }
        }

按如下方式处理datagridView的
DataBindingComplete
事件

  private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            foreach (DataGridViewRow r in dataGridView1.Rows)
            {
                r.Cells[1] = new DataGridViewLinkCell();
            }
        }
对于Vb.Net极客

For Each typeCell As DataGridViewRow In FlxInvTransaction.Rows
    Dim linkCell As New DataGridViewLinkCell
    linkCell.Value = typeCell.Cells(2).Value
    typeCell.Cells(2) = linkCell
Next
对于Vb.Net极客

For Each typeCell As DataGridViewRow In FlxInvTransaction.Rows
    Dim linkCell As New DataGridViewLinkCell
    linkCell.Value = typeCell.Cells(2).Value
    typeCell.Cells(2) = linkCell
Next

请告诉我c#中的代码,当我在c#中编码时,请检查标记请告诉我c#中的代码,当我在c#中编码时,请检查标记因为我是新手,你能告诉我这个句柄将如何被触发吗?在visual Studio中单击属性窗口中的DataGridGrid单击事件图标查看事件列表查找数据绑定完成。抱歉,响应太晚。由于我是新手,您能告诉我此句柄将如何触发吗?在visual Studio中,单击“属性”窗口中的DataGridGrid单击事件图标查看事件列表查找数据绑定完成。很抱歉反应太晚。