3 Replies - 1576 Views - Last Post: 04 October 2012 - 12:08 AM Rate Topic: -----

#1 kaswin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-October 12

comparing data from datagridview c#

Posted 03 October 2012 - 07:41 PM

pls look the image at the attachmentsAttached Image.. how can I compare both datagridview by using ID?As you can see, I want to compare both datagridview based on their id, for example id 1,2 are in both the datagridview... so i want help how to compare both the datagridview...if the id match I want the value in the Inquiry column to be sent to another datagridview...for example Inquiry value 8989 and 1111 to be sent to another datagridview...can anyone help me out??? thanks

Is This A Good Question/Topic? 0
  • +

Replies To: comparing data from datagridview c#

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3491
  • View blog
  • Posts: 10,748
  • Joined: 05-May 12

Re: comparing data from datagridview c#

Posted 03 October 2012 - 09:57 PM

What's wrong with a simple iteration with through one DataGridView's rows and comparing against the other DataGridView's rows, if the number of rows is small? It'll be an O(n^2) operation, but if n is small, it shouldn't matter too much.

You can use a a Dictionary to insert all the ID and corresponding Inquiry values. The actual lookup's will be O(1), but I think overall, it'll be an O(n) to initially insert the keys and values from one DataGridView, and then perform the lookup using the ID's from the other DataGridView.

This post has been edited by Skydiver: 03 October 2012 - 09:58 PM

Was This Post Helpful? 0
  • +
  • -

#3 kaswin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-October 12

Re: comparing data from datagridview c#

Posted 03 October 2012 - 11:59 PM

View PostSkydiver, on 03 October 2012 - 09:57 PM, said:

What's wrong with a simple iteration with through one DataGridView's rows and comparing against the other DataGridView's rows, if the number of rows is small? It'll be an O(n^2) operation, but if n is small, it shouldn't matter too much.

You can use a a Dictionary to insert all the ID and corresponding Inquiry values. The actual lookup's will be O(1), but I think overall, it'll be an O(n) to initially insert the keys and values from one DataGridView, and then perform the lookup using the ID's from the other DataGridView.

I dont understand what are u trying to say... I am a beginner for c# only
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3491
  • View blog
  • Posts: 10,748
  • Joined: 05-May 12

Re: comparing data from datagridview c#

Posted 04 October 2012 - 12:08 AM

The comments I made about O(n), O(1), and O(n^2) were notes about how potentially expensive the set of steps will be. Ignore them for now.

Just focus on getting the IDs from each row of one DataGridView and comparing them against the IDs found in the other DataGridView.

What book are you reading, or what tutorial are you following to learn C#?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1