After searching long and hard I finally found a way to do it. Makes me wonder why I didn't think of this before. 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; } }
Donnelly James
Posts
-
How to auto-select a newly added row in the DataGrid? [modified] -
How to auto-select a newly added row in the DataGrid? [modified]I'm sorry I'm taking so long to reply to this thread, I'm a little busy. Ok so everything you said works but now how do I select the newly added row. I've tried several ways so far. e.g. this.bindingsource.contains(NewID), this.bindingsource.find(NewID). this.bindingsource.FindRows(NewID). But they never select any row except the very first row.
-
How to auto-select a newly added row in the DataGrid? [modified]It's an SQL Server database and we do have identity columns but they are no primary key columns. I am able to use @@Identity and Scope_Identity() in the Delphi App and it works fine. I just need to figure out how to do it in C#.
-
How to auto-select a newly added row in the DataGrid? [modified]If anyone is familiar with Delphi and it's TADOQuery component, I would like to do something similar to the TADOQuery.Locate method. If your not familiar with Delphi's TADOQuery.Locate, I want to be able to programatically select a newly added row. So the user can have a visual reference that a post was successful. I read online sometime a ago that the TableAdapter.Select() method was the way to go but I can't seem to get it to work. Anyone? 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.
modified on Friday, April 16, 2010 4:53 PM