Solved

Changing value of system data column in datagrid

Posted on 2014-03-18
3
570 Views
Last Modified: 2014-03-19
Hi,
I have a datagridview in my windows form where on load I'm creating an additional column in my datagridview with a checkbox in it.  This is for users to be able to select a record and then complete an action on it.  

I have added a textbox and a button to my form.  I want the user to key in a value in the textbox and when they click the button the system will compare a specific column value for each row in the datagridview to the value in the textbox.  If the column value is less than or equal to the textbox value then make the checkbox  value equal selected.

I've found something similar to what I need but this will only allow me to check if the values are equal.
 
Private Sub btnSelectLowAmt_Click(sender As System.Object, e As System.EventArgs) Handles btnSelectLowAmt.Click
        searchvalue2 = CInt(mtxtLowAmt.Text)
        Dim rowIndex As Integer = -1
        For Each row As DataGridViewRow In DataGridView2.Rows
            If row.Cells(7).Value.Equals(searchvalue2) Then
                row.Cells(0).Value = True
                Exit For
            End If
        Next
    End Sub
0
Comment
Question by:imstac73
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39938207
You should just need to change the line:
If row.Cells(7).Value.Equals(searchvalue2) Then

Open in new window

To:
If Integer.Parse(row.Cells(7).Value.ToString()) <= searchvalue2 Then

Open in new window

That assumes that your column will always contain a numeric value. If potential exists for it to be non-numeric, then you will need to perform additional checks first.
0
 

Author Comment

by:imstac73
ID: 39938215
Thanks Carl, I will try it out tomorrow and let you know how it goes.
0
 

Author Comment

by:imstac73
ID: 39940622
Carl,
That worked perfect.  Thank you.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now