Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
How to compare two Grids column values?
posted

Hi

  I am working on a .NET 2.0 project using UltraWingrid. I have 2 grids on my Form. I am binding the two grids with two datasets, dataset1 and dataset2 for Grid1 and Grid2 respectively.

Once the data is loaded to the grids I want them to be compared and here both the grids columns are same with each other, but the records count need not be the same.

I want to compare the values in the first grid with the values in the second grid and show the difference as follows:

For example:

SNO SupId ProdDescription
3 C CC
4 D DD
5 E EE
1 A AA
2 B BB
SNO SupId ProdDescription
6 F FF
7 G GG
1 A AA
2 B BB

=>If both Grid1 and Grid2 has same values in all the cells in a Row i dont want to highlight

=>If Grid1 record not found in Grid2 then the Forecolor of that record in Grid1 should be in green.

=>If Grid2 record  not found in Grid1 then the forecolor of that record in Grid2 should be in red.

=>Finally the returned records sholud be shown as above in the Grids, Sorted by Color.

For the above Key columns to compare two grid records are RollNo and Name.

How to achieve this without looping through the grid?

Thanks

Sinesh N

  • 37774
    posted

    I posted a response to this question last week at this thread:

    http://news.infragistics.com/forums/t/20321.aspx

    Basically I don't see how you could do this without looping since how are you going to check if the record exists otherwise.  My response in the other thread shows a way to accomplish this while leveraging the grid's filtering capabilities.  If your grid's data is never changing, you could also keep a Hashtable/Dictionary of all the values in the column and use that as a lookup table to see if a value exists, but this has the downside that you're now duplicating all of your data.

    -Matt