i have one datagridview.in my datagridview is having four row and three columns.after enter the one row. that row one coloumns value repeat (or) same in second row columns value.so,how to find out the which value is repeat and which row.
i have one datagridview.in my datagridview is having four row and three columns.after enter
Share
If your grid data is mainly text then maintain a
List<string>that holds all of the values being inserted in the DataGridView.So every time data was entered in a cell (there are events you can handle for that, like
CellEndEditorCellLeave), you check if it is in your list of strings before you add it.If it is, then you found a value already contained within the grid.
EDIT
Here is some sample code:
NOTE
This routine is very basic, it only checks if values being entered in the grid are
already in the
List<string>.However, let’s say that you already have value test in one cell and already in the
List<string>.What happens when you delete that value and enter a test1 ? Well, test will still be in
List<string>and next time you enter test in another cell you’ll get theMessageBoxsaying there is already a test in the grid, which could be wrong.