Solved

Changing value of system data column in datagrid

Posted on 2014-03-18
3
568 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

16 Experts available now in Live!

Get 1:1 Help Now