Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DataGridView Default Error Dialog when closing a Windows Form

Posted on 2009-04-01
5
Medium Priority
?
1,572 Views
Last Modified: 2013-11-26
My application is written in VS 2008, VB, .Net 3.5 and have three forms that stack on top of each other due to previous selection (Master Form, Patron Form & Members Form).
When I close the Patron Form I get the "DataGridView Default Error Dialog" (See attached form).

Can anyone help me figure out why and how to resolve this error?

Process to replicate error:
1) Launch Application.
2) Select Patron Form form Master Form.
3) Type in a Patron ID.
4) Click on the Search Button.
5) Retrieves that Patron's information.
6) Click on the [X] to Close form.
7) ERROR...."DataGridView Default Error Dialog"

Material-Basic.jpg
DataGridView-Default-Error-Dialo.JPG
0
Comment
Question by:ITCSAdmin
[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
  • 2
5 Comments
 
LVL 9

Assisted Solution

by:Deathrace
Deathrace earned 500 total points
ID: 24041338
Hi,
If you don't have any error handlers in your procedures error will be raised by the CLR. To avoid that you need to have some similar.
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, _
                                      ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
                                      Handles DataGridView1.CellEndEdit
    Try
        '
        'all of your main logic goes here
        '
    Catch ex As Exception
        MessageBox.Show(ex.Message)
        '...
    End Try
 
End Sub

Open in new window

0
 

Author Comment

by:ITCSAdmin
ID: 24042000
Deathrace,
Sorry for wrong form page in previous message....
I tried your suggestion for both DataGridViews that I have on this form and I am still getting the same error. I think it is with one of the ComboBoxes.
See code and correct form below.


    'Members DataGridView
    Private Sub P_MembersDataGridView_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles P_MembersDataGridView.DoubleClick
        'Dim wf2 As New wfPatron_Member
        'Dim row As DataSet_Patron_Main.P_MainRow
        'row = CType(CType(Me.P_MainBindingSource.Current, DataRowView).Row, DataSet_Patron_Main.P_MainRow)
        'wf2.Show(row.Patron_ID)
 
 
        Dim wf2 As New wfPatron_Member
        Dim m As Integer
 
        'Get Patron_ID and Show wf2 - WORKING
        'wf2.Patron_IDTextBox.Text = Me.Patron_IDTextBox.Text
        'wf2.Show()
 
        'MsgBox("DataGridView 1 Row = " & P_MembersDataGridView.SelectedRows.Count)
 
        Try
            For m = 1 To 10
                If P_MembersDataGridView.SelectedRows.Count = m Then
                    wf2.MdiParent = Me.MdiParent
                    wf2.Member_IDToolStripTextBox.Text = P_MembersDataGridView.SelectedRows(0).Cells("MemberIDColumn").Value.ToString()
 
                    wf2.FillBy_Member_IDToolStripButton.PerformClick()
                    wf2.ShowDialog()
                    wf2.Dispose()
                Else
                End If
            Next
        Catch ex As Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
 
        'Get Member_ID and Show wf2 - NOT WORKING
 
    End Sub
 
    Private Sub P_MembersDataGridView_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles P_MembersDataGridView.CellEndEdit
        Try
 
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
 
    Private Sub Patron_CommentsDataGridView_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Patron_CommentsDataGridView.CellEndEdit
        Try
 
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

Open in new window

Patron-Screenshot.JPG
0
 
LVL 9

Assisted Solution

by:Deathrace
Deathrace earned 500 total points
ID: 24114229
first place all your combo box stuff inside try and catch block.
0
 

Author Comment

by:ITCSAdmin
ID: 24115458
Deathrace,

Thanks for looking at my problem, but I am a New Programmer and so please expand upon what you said.

ITCS Admin
Damon
0
 
LVL 15

Accepted Solution

by:
oobayly earned 500 total points
ID: 24115624
It sounds like a new record is somehow being added to the top datagridview. If the new record has for example a DBNull value for "Member Status", which is not a valid value for the combobox. The error is only displayed when the datagridview loses focus (ie. when the form closes).

You might want to handle the DefaultValuesNeeded event for the DataGridView, and use it to populate valid values for the cells that are displayed using the comboboxes.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
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…

618 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