We help IT Professionals succeed at work.
Get Started

What Events fire when a TabPage is loaded?

BlakeMcKenna
BlakeMcKenna asked
on
84 Views
Last Modified: 2015-03-11
I'm having a problem with a two of TabPages (TB) and not sure how to resolve the issue. First, the problem is that I have a DataGridView (DGV) on each of the TB's that when loaded they will show color in specific cells based on certain criteria. This functionality occurs as the result of a call from within the "Enter" Event of each TabPage. It's the last line of code executed in each Event. When the TB loads, the routine executes and does what it should, however, the specific cells are not colored as they should be. The weird thing is that when I click on another TB and then click on the previous TB, everything works fine. So, it seems on initial load that this functionality isn't working but once I toggle the TB's...they both work fine.

Here is the routine that does the coloring:

    Private Sub FormatGridRepeat()
        Try
            Dim rIDX As Integer = 0
            Dim maxError As Decimal = 0
            Dim blnFirstTime As Boolean = True

            EH.ErrorMessage = String.Empty

            If blnFormatRepeatabilityGrid Then
                For Each row As DataGridViewRow In dgvRepeatability.Rows
                    If Not stcDefaultValues.repeatabilityMIN Is Nothing And Not stcDefaultValues.repeatabilityMAX Is Nothing Then
                        If CInt(row.Cells(2).Value) <> 0 Then
                            If blnFirstTime Then
                                blnFirstTime = False
                                If IsNumeric(row.Cells(4).Value) Then
                                    maxError = CDec(row.Cells(4).Value)
                                End If
                            End If

                            If row.Cells(4).Value.ToString.Length > 0 Then
                                If IsNumeric(row.Cells(4).Value) Then
                                    If CDec(row.Cells(4).Value) >= maxError Then
                                        maxError = CDec(row.Cells(4).Value)
                                        rIDX = row.Index
                                    End If
                                End If
                            End If

                            If IsNumeric(row.Cells(4).Value) Then
                                If (CDec(row.Cells(4).Value) < CDec(stcDefaultValues.repeatabilityMIN)) Or (CDec(row.Cells(4).Value) > CDec(stcDefaultValues.repeatabilityMAX)) Then
                                    dgvRepeatability.Rows(row.Index).Cells(4).Style.BackColor = Color.Salmon
                                End If
                            End If
                        End If
                    End If
                Next

                If CDec(dgvRepeatability.Rows(rIDX).Cells(2).Value) <> 0 Then
                    If (CDec(maxError) < CDec(stcDefaultValues.repeatabilityMIN)) Or (CDec(maxError) > CDec(stcDefaultValues.repeatabilityMAX)) Then
                        dgvRepeatability.Rows(rIDX).Cells(4).Style.BackColor = Color.Salmon
                    Else
                        dgvRepeatability.Rows(rIDX).Cells(4).Style.BackColor = Color.PaleGreen
                    End If
                End If
            End If

            dgvRepeatability.ClearSelection()

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

Open in new window


Is there another Event that fires after the "Enter" Event that I could perhaps insert this call?

Thanks!
Comment
Watch Question
Senior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE