Results 1 to 8 of 8

Thread: Find And Get Data In Datagridview With Condition / Statement

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2012
    Location
    INDONESIA - BALI
    Posts
    27

    Question Find And Get Data In Datagridview With Condition / Statement

    Hello Guys!

    I have problem with my project, I dont know how to impelementation Search and Get data in datagrid view with statement, I mean with WHERE.

    This is the ilustration :

    Let's Say The Table Below A Datagridview, with 5 Columns and 5 Rows.

    Name:  New.JPG
Views: 2107
Size:  25.7 KB

    The example of my problem, in S1 :

    1. Check Ranking A = Ranking B?
    [NO]

    2. Find Ranking B that have Value = Ranking A!
    Row-2 [S2]

    3. Take Nilai B in the Row-2!
    [0.9]

    4. Find the difference between Nilai B in S1 and S2
    [0.9 and 0.6 = 0.3]

    5. Add new Columns and Put 0.3 right there.

    And The Result Will be like this :

    Name:  New2.JPG
Views: 1989
Size:  28.0 KB

    I dont Understand about Step 2 and Step 3, Somebody please Help Me! I’m confuse because there is no WHERE in VB.Net to make Condition!
    Last edited by vher_way; Dec 29th, 2013 at 07:30 PM.

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Find And Get Data In Datagridview With Condition / Statement

    I think you may be able to do this by adding a new column to the underlying data table and settings its expression property correctly.

    DataColumn.Expression Property
    Take a look at the IIF function; about 3/4 of the way down on that page.

    The reason I say I think is because I don't quite understand what you want. In particular
    2. Find Ranking B that have Value = Ranking A!
    Row-2 [S2]
    Can you elaborate?
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2012
    Location
    INDONESIA - BALI
    Posts
    27

    Re: Find And Get Data In Datagridview With Condition / Statement

    Thanks For Replay!

    I use S1 for example to explain my problem!
    S1 Have Ranking A = 1
    S1 Have Ranking B = 4
    S1 Have Nilai A = 80
    S1 Have Nilai B = 0.9

    First : Check Did Ranking A = Ranking B [1=4] --> NO

    Okay..

    Then : Find Data In Ranking B Coulmn Where The Value = Ranking A in Row S1 ---> So Find Data In Ranking B Column Where The Value = 1

    The answer is : A value of 1 is on Second Row.

    The Second Row Is S2
    S2 Have Ranking A = 3
    S2 Have Ranking B = 1
    S2 Have Nilai A = 70
    S2 Have Nilai B = 0.8

    Then : Find Difference between Nilai B Second Row and Nilai B in First Row ->> 0.9 - 0.8 = 0.1

    Do you understand what i Mean?

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 2012
    Location
    INDONESIA - BALI
    Posts
    27

    Unhappy Re: Find And Get Data In Datagridview With Condition / Statement

    Please Help Me Broo!!

    I realy Don't Understand, This Is My Final Problem! Testing Phase On My research!!

  5. #5
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Find And Get Data In Datagridview With Condition / Statement

    Where is this data coming from? Is there an underlying datatable or are these values added directly from some process?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  6. #6
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Find And Get Data In Datagridview With Condition / Statement

    Did you look at the DataColumn.Expression property? Will that work for you? Have you written any code for this? If so what does it look like? Does it do what you would expect? Do you have the data that is in the datagridview? Is it in a table or do you populate the grid manually? You are the one that know what needs to happen to the data; you have it fairly well laid out above in pseudo code, now you just need to code it. I hope you are not expecting some to do that for you, because that would defeat the reason I visit this site. Give it a go and if you get stuck, post relevant code and good questions.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2012
    Location
    INDONESIA - BALI
    Posts
    27

    Re: Find And Get Data In Datagridview With Condition / Statement

    I'm using MySQL to acces the data.. That picture in first post just example, this is the real my datagridview :

    Name:  What.JPG
Views: 2607
Size:  221.3 KB

    I have been try to solve this problem, but i dont understand:


    Code:
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            dgv.Columns.Add("Diff", "Diff")
            For i As Integer = 0 To dgv.Rows.Count - 1
                For j As Integer = 0 To dgv.Columns.Count - 1
                    If dgv.Rows(i).Cells(1).Value <> dgv.Rows(i).Cells(2).Value Then
    
                    WHAT NEXT?
    
                    End If
    
                Next
            Next
        End Sub
    Last edited by vher_way; Dec 29th, 2013 at 07:40 PM.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Find And Get Data In Datagridview With Condition / Statement

    Well, help has been offered but you have refused to heed it so far. If you're getting the data from the database then you should be binding it to the grid, in which case you should not be touching the grid at all for what you want. You should be working exclusively with the bound data. As has been said, if you want another column then add another column to the underlying DataTable that you have bound to the grid. You can then set the Expression property of that DataColumn to populate it based on the values in other columns. You've already been directed to the Expression property of the DataColumn class. Have you read the documentation for that property? I assume not but I have to wonder why not. You want help but you're not prepared to read something that will help you when someone points you to it. Don't just sit there waiting for someone to write your code for you.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width