我正在获取数据并存储在datatable中,以便在数据网格视图中显示它,如何使datatable的第二列visitdate与link type一样?像这样的东西
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();发布于 2013-10-17 10:49:57
在将DataTable(dt)设置为DataGridView的数据源后添加此代码。
foreach (DataGridViewRow row in dataGridViewVisits.Rows)
{
DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
linkCell.Value = row.Cells[1].Value;
row.Cells[1] = linkCell;
}一定会成功的..。:)
发布于 2013-10-17 10:50:14
处理DataBindingComplete事件的datagridView如下所示。
private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
foreach (DataGridViewRow r in dataGridView1.Rows)
{
r.Cells[1] = new DataGridViewLinkCell();
}
}发布于 2020-04-09 10:27:29
对于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
Nexthttps://stackoverflow.com/questions/19423320
复制相似问题