Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Changing value of system data column in datagrid

Posted on 2014-03-18
3
Medium Priority
?
588 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

782 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