Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

.NET Comparing 2 datagridview, vb.net

views
     
ISawYou
post Feb 13 2012, 05:28 PM

On my way
****
Senior Member
531 posts

Joined: Oct 2011
From: Tawau -> Menumbok, Sabah(Land Below The Wind)



QUOTE(silvestrelsl @ Feb 21 2011, 04:10 PM)
It is not really complicated to compare 2 data grid view with same row position.
I believe you have access to both dataset.
The code is simple as below:

CODE

DataSet ds = datagridview1.DataSource;          [COLOR=red]<<<<This part[/COLOR]
DataSet ds2 = datagridview2.DataSource;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
 for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
 {
   if (ds.Tables[0].Rows[i][j].ToString() == ds2.Tables[0].Rows[i][j].ToString())
   return true;
 }
}


Be warn, need some more tweaking if you have a lot of records in the dataset.
*
I'm sorry that I'm so weak I can't do it. Needed thorough guide pls, in VB2010. How to do the above part ? assuming my values were inserted directly into DGV without using datatsources..

 

Change to:
| Lo-Fi Version
0.0153sec    0.41    6 queries    GZIP Disabled
Time is now: 15th December 2025 - 08:32 PM