Eline Sami

Eline Sami

  • NA
  • 47
  • 70.2k

remove duplicates from datagridview - c#

Jun 1 2015 12:07 AM
Hello
 
In my windows form application, I have a datagridview with four columns. my datagridview is NOT bound to a data source. but it reads data from different application during the runtime.
 
How to prevent adding new rows during the run time if the Patient ID is already exist in the table?
 
Example:
 
PatientID   PatientName      Gender      Age
Abcd1234   xxxxxx                   xxxxxx       xxxxxx   
FIxIlm568    xxxxxx                   xxxxxx       xxxxxx   
na7a5419    xxxxxx                   xxxxxx       xxxxxx   
 
If for example the patientId found twice on the list, then the datagridview will not add another row with that patientID. the new row will be deleted automatically (if the patientID got duplicated).
 
 
Can you help me on this, plz?
 

Answers (5)