I want to be able to programatically select a newly added row that was added in another screen and not directly in the Grid. So the user can have a visual reference that a post was successful.
I found this answer here:
http://www.akadia.com/services/dotnet_find_methods.html
but it requires your tables to have primary keys and just my luck none of my tables have primary keys. By the way I didn't create these tables. How do I do the find without primary keys? I don't want to have to add them to all my Tables. My tables do have Unique Identity columns and I use the "select scope_identity()..." to return the new ID but I am unable to use this new ID the select it from the Grid.
Loading

Hirendra SisodiyaRank #258 · 9.8K reputationPosted Apr 23, 2010, 12:59 AM EDT
Hello Donelly
i dont know how you are add new row in DataGridView...
But you do this like
you need to know index of newly added row suppose that if your new row always add in the last position then you can usethiscode:
int Index;
Index = dataGridView1.Rows.Count-1;
dataGridView1.Rows[Index].Selected = true;
// otherwise you need to findout that index
thanks
please mark as answere if it helps
Donnelly James46 reputationPosted Apr 23, 2010, 5:26 AM EDT
Donnelly James46 reputationPosted Apr 23, 2010, 7:07 AM EDT
for ( int i = 0; i < GridContact.Rows.Count; i++ )
{
if ((int)GridContact.Rows[i].Cells[1].Value == ID )
{
GridContact.ClearSelection();
GridContact.Rows[i].Selected = true;
}
}
Thanks to Hirenda for leading me in the right direction.
Hirendra SisodiyaRank #258 · 9.8K reputationPosted Apr 23, 2010, 8:47 PM EDT
now you are doing right.........great..
thanks