Solved

Changing value of system data column in datagrid

Posted on 2014-03-18
3
573 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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