Highlighted
Absent Member.
Absent Member.
1613 views

Compare with another datagrid datagrid

  1. hello ,
    
    I wonder if it is possible comparisons between datagridview 


    thanks
0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Compare with another datagrid datagrid

I am not sure what you are asking for. In the post that was e-mailed to me there was some example code in vb but it does not appear in this post.

Did you want the vb code converted to COBOL or were you asking for something else?

The code shows as:

6.	Private Sub DataGridView1_SortCompare( _
7.	
8.	    ByVal sender As Object, ByVal e As DataGridViewSortCompareEventArgs) _
9.	
10.	    Handles DataGridView1.SortCompare
11.	
12.	
13.	
14.	    ' Try to sort based on the contents of the cell in the current column.
15.	
16.	    e.SortResult = System.String.Compare(e.CellValue1.ToString(), _
17.	
18.	        e.CellValue2.ToString())
19.	
20.	
21.	
22.	    ' If the cells are equal, sort based on the ID column.
23.	
24.	    If (e.SortResult = 0) AndAlso Not (e.Column.Name = "ID") Then
25.	
26.	        e.SortResult = System.String.Compare( _
27.	
28.	            DataGridView1.Rows(e.RowIndex1).Cells("ID").Value.ToString(), _
29.	
30.	            DataGridView1.Rows(e.RowIndex2).Cells("ID").Value.ToString())
31.	
32.	    End If
33.	
34.	
35.	
36.	    e.Handled = True
37.	
38.	
39.	
End Sub
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Compare with another datagrid datagrid

sorry , I sent the wrong code, but need to make a comparison between two datagridview and bring the differences between the two

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Compare with another datagrid datagrid

What are you actually comparing between the two grids, a 1 to 1 comparison by cell, so comparing grid1 row 1 col 1 with grid2 row 1 col 1, grid1 row 1 col2 with grid2 row 1 col2, etc.? Are you using data binding to a List, collection  or Dataset, etc?

How do you want the differences returned?

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.