Try executing one more line:
proNamDetDataGridView.CurrentCell = proNamDetDataGridView.Rows[rowIndex].Cells[0];
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi All
how to set record pointer to current record in datagridview. i am used DataTable in C#
without database
i am added image
i am using code
int rowIndex = -1;
foreach (DataGridViewRow row in proNamDetDataGridView.Rows)
{
if (row.Cells["PND_Id"].Value.ToString().Equals(pndid))
{
rowIndex = row.Index;
proNamDetDataGridView.Rows[rowIndex].Selected = true;
break;
}
}
get row value is wrong means, i am selected row is last one for modify. but got value from first row
because record pointer is stay in first row, i want to set record pointer at same selected row
can possible it?. if it. please provide some code snippets.
with best Regards
NazHim
Try executing one more line:
proNamDetDataGridView.CurrentCell = proNamDetDataGridView.Rows[rowIndex].Cells[0];
hello Viorel-1
thanks for your fast response
i am tryed.
proNamDetDataGridView.CurrentCell = proNamDetDataGridView.Rows[rowIndex].Cells[0];
but getting error..!
System.InvalidOperationException: 'Current cell cannot be set to an invisible cell.'
with best regards
NazHim
Thanks Viorel-1
it's worked fine
int rowIndex = -1;
foreach (DataGridViewRow row in proNamDetDataGridView.Rows)
{
if (row.Cells["PND_Id"].Value.ToString().Equals(pndid))
{
rowIndex = row.Index;
proNamDetDataGridView.Rows[rowIndex].Selected = true;
proNamDetDataGridView.CurrentCell = proNamDetDataGridView.Rows[rowIndex].Cells[1];
break;
}
}
thanks for your valubale advice