Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cannot code the CellValueChanged Event?

Posted on 2014-10-07
17
Medium Priority
?
222 Views
Last Modified: 2014-10-07
What DataGridView Event should be used in order to check the value of an invisible cell?
0
Comment
Question by:BlakeMcKenna
[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
  • 8
  • 6
  • 3
17 Comments
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 40365993
I am assuming that this is a Windows form application because you are using a DataGridView. You should be able to create it. How are you attempting to create it and what do you mean by it will not come up in code behind?
0
 

Author Comment

by:BlakeMcKenna
ID: 40366013
Fernando,

You are correct, it is a Windows App. I'm basically just referencing the DGV from the Control Dropdown list in the designer and then click the desired event from the Events Dropdown list.
0
 

Author Comment

by:BlakeMcKenna
ID: 40366015
Sorry, here is a screenshot.
Screenshot.jpg
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 64

Expert Comment

by:Fernando Soto
ID: 40366067
Hi BlakeMcKenna;

I was more interested in the signiture of the CellValueChanged event method you used. See if your event method matches this one. Note that in the below event it is using DataGridView1 as the instance name please change the two places where that occurs to use it in your code.

Private Sub DataGridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged

End Sub

Open in new window

0
 
LVL 40
ID: 40366123
What do you mean exactly by "Cannot code the CellValueChanged Event?"

Simply select it in the DropDown ???
0
 

Author Comment

by:BlakeMcKenna
ID: 40366173
That's my problem...I can't create the CellValueChanged Event by simply selecting the dgv name and then selecting the CellValueChanged Event. When I do that...the cursor is placed within an existing Event for that dgv. The application isn't running either. I'm in design view within the code-behind.
0
 

Author Comment

by:BlakeMcKenna
ID: 40366182
Fernando,

I was able to create it manually by typing in the event. But now I get the following error (see attachment).
Screenshot.jpg
0
 
LVL 64

Assisted Solution

by:Fernando Soto
Fernando Soto earned 1000 total points
ID: 40366195
What happens when you place that method in your code and write the code in it to handle the event?

Also you may want to do a Build -> Clean Solution from Visual Studio main menu. compile it and see if the event shows up in the drop down list.

I have seen at times when an event does not show up in the drop down, but when you just add the event by hand it works fine.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1000 total points
ID: 40366203
IsDBNull works with data that comes from a database, either in a DataTable or a DataReader. You cannot use it for .NET objects. For these, you use the notion of Nothing instead:

If row.Cells(12).Value IsNot Nothing then
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 40366212
Hi BlakeMcKenna;

This is a different issue now look at James post above.
0
 

Author Comment

by:BlakeMcKenna
ID: 40366279
Guys,

I actually have the Event firing now...just not sure why the code isn't working even though it gets executed.

Although I still don't know why I am unable to select the Event from the DropDown List even though the Event is listed.

    Private Sub dgvSTEquipmentAvail_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles dgvSTEquipmentAvail.CellValueChanged
        Try
            If Not blnIsLoaded Then
                If e.RowIndex >= 0 Then
                    Select Case e.ColumnIndex
                        Case 12
                            If Not IsDBNull(dgvSTEquipmentAvail.Rows(e.RowIndex).Cells(12).Value) Then
                                If dgvSTEquipmentAvail.Rows(e.RowIndex).Cells(12).Value > 0 Then
                                    If dgvSTEquipmentAvail.Rows(e.RowIndex).Cells(12).Value = gWorkStation_ID Then
                                        Dim cboSelected As DataGridViewCheckBoxCell = dgvSTEquipmentAvail.Rows(e.RowIndex).Cells(0)

                                        cboSelected.Value = True
                                        dgvSTEquipmentAvail.Rows(e.RowIndex).Cells(0).Selected = True
                                    End If
                                End If
                            End If
                    End Select
                End If
            End If

        Catch ex As Exception
            EH.ErrorMessage = "frmCalibration_3/dgvSTEquipmentAvail_CellValueChanged() - " & ex.Message & "...Contact Engineering!" & "~E"
        End Try
    End Sub

Open in new window

0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 40366294
What exception are you getting and inner exception ?
0
 
LVL 40
ID: 40366335
Usually, when you can't get the event procedure from the drop down, it's because the application is running. In such a situation, the dropdown can be used to navigate in already written code, but it cannot generate new events. They should display the uncoded events in grey when the code is running.
0
 

Author Comment

by:BlakeMcKenna
ID: 40366340
I got it working. Here is my code below. I actually went back to the CellFormatting Event...and Fernando, I basically restarted Visual Studio and was able to create the CellValueChanged Event in the normal fashion!
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 40366346
Thanks for your help guys!
0
 

Author Comment

by:BlakeMcKenna
ID: 40366369
James,

Fortunately that didn't take to much to figure out. That's usually the first thing I check and I usually find out when I try to make changes in the code and can't even hit the "Enter" key.

Thanks again!
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 40366373
Not a problem, glad to help.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

688 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