Victor Charles
asked on
Help with changing cell color for mismatch column based on identical IDs
How do you loop through a DataGridView and based on the same SN values, compare the rows and other columns and if they don't match change the cell colors of the data in unmatched columns to red?
For example If I have:
SN CTRY Item
10411 BEL BMW
10411 BEL Toyota
10421 USA Jeep
10451 USA Jeep
Only the first two rows should be compared because they both have SN = 10411 and cells for "Item" column in those two rows should be red (Text color).
Thanks,
Victor
For example If I have:
SN CTRY Item
10411 BEL BMW
10411 BEL Toyota
10421 USA Jeep
10451 USA Jeep
Only the first two rows should be compared because they both have SN = 10411 and cells for "Item" column in those two rows should be red (Text color).
Thanks,
Victor
ASKER
Hi,
The data is from a DataTable.
There will be more than three column and more than than two rows with the same SN.
Thanks.
The data is from a DataTable.
There will be more than three column and more than than two rows with the same SN.
Thanks.
So in the below case the first four rows have the same values in the SN column so which cells in the other two columns get colored Red?
SN CTRY Item
10411 BEL BMW
10411 BEL Toyota
10411 BEL Nissan
10411 USA BMW
10421 USA Jeep
10451 USA Jeep
ASKER
Hi,
It would only be the Item column, but if I had another column "ItemA" where the first four rows were not the same the cells in those rows would also be red.
Victor
It would only be the Item column, but if I had another column "ItemA" where the first four rows were not the same the cells in those rows would also be red.
Victor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You. I will try it and get back to you.
OK.
ASKER
Hi,
Do I need to import something?
I received error message:
DataGridViewRowCollection is not Queryable make sure you are not missing a reference.......
on line
Dim colorCells = From row As DataGridViewRow In C1Grid1.Rows _
But I don't get the same error for C1Grid1 on the other part of the code.
Thanks,
V.
Do I need to import something?
I received error message:
DataGridViewRowCollection is not Queryable make sure you are not missing a reference.......
on line
Dim colorCells = From row As DataGridViewRow In C1Grid1.Rows _
But I don't get the same error for C1Grid1 on the other part of the code.
Thanks,
V.
Is C1Grid1 the DataGridView control?
Where you implemented the code, is the data table been filled with data and assigned to C1Grid1 so that it is not empty?
Where you implemented the code, is the data table been filled with data and assigned to C1Grid1 so that it is not empty?
ASKER
Hi,
I added system.linq to remove the error.
will get back to you shortly.
V.
I added system.linq to remove the error.
will get back to you shortly.
V.
Very good.
ASKER
Hi,
It works Perfectly!
How do I highlight the rows with a perfect match?
Thank You!
Victor
It works Perfectly!
How do I highlight the rows with a perfect match?
Thank You!
Victor
ASKER
Hi,
I will ask my last question in a new post.
Thanks again.
Victor
I will ask my last question in a new post.
Thanks again.
Victor
A couple of questions.
What is the data source for the data grid view, is it a DataTable object or something else?
Will there be only three columns in the data grid view or more?
Will there be a max of only two rows that can have the same SN or can there be more?