Why am I getting a System.StackOverflowException when assingning a value to avariable.
I have used the same process on other forms in this project and they work fine, don't know why this is happening.
This is the error "An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll"
the exception hapens on this line link = Me.dgvShipping.Rows(e.RowIndex).Cells("Link").FormattedValue

    Private Sub dgvShipping_CellFormat(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles dgvShipping.CellFormatting
        Dim columname As String = Me.dgvShipping.Columns(e.ColumnIndex).Name
        Dim link As String = ""
        Try
            If Not IsDBNull(e.Value) Then
                link = Me.dgvShipping.Rows(e.RowIndex).Cells("Link").FormattedValue
                Select Case columname
                    Case "Address"
                        If Me.dgvShipping.Rows(e.RowIndex).Cells("Reschedule").FormattedValue Then
                            e.CellStyle.BackColor = Color.Yellow
                        End If
                End Select
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

One problem could be here If Not IsDBNull(e.Value) Then try checking for Nothing instead of DBNull If e.Value IsNot Nothing Then

Thanks tinstaafl for your reply but that is not it I still get the error.

I would suggest setting a break point on that line and examine all the objects/values being used in it. It looks to me like a bad object/value is being used.

this is what I did
I Added a second datagrid just for a test but left the first one.
Now I have dgvShipping and datagrid2. I placed the exact code that I posted previously in datagrid2.CellFormatting and I don't receive the Exception it worked.
Than I went and deleted the first datagrid and changed the code to reference datagrid2 inlieu of dgvShipping again I received the error. So now I have it working with two datgrids.
By this outcome I hope someone has a solution so that I dont have to use 2 datagids.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.