Results 1 to 3 of 3

Thread: [RESOLVED] TabPage index is invalid but visible?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2022
    Posts
    83

    Resolved [RESOLVED] TabPage index is invalid but visible?

    I am invalidating a new column of a DataGridview (that resides on TabPages(1) of TabControl2 on Form1) from another class, which has worked successfully until now. Recently, the line of code below starting throwing the exception "System.ArgumentOutOfRangeException: 'InvalidArgument=Value of '1' is not valid for 'index'."

    At run-time, immediately before execution of this line of code, I can see the data on the DGV but the tabs are invisible.

    Code:
    Dim main As Form1 = CType(Application.OpenForms(0), Form1)
    
    For j = 1 To NumNewCols
       CType(main.TabControl2.TabPages(1).Controls("dgv1"), DataGridView).InvalidateColumn(NumOrigCols + j - 1) 
    Next
    FYI - there is no threading involved. There is a delegate to the DGV which is used when the DGV is updated from a threaded method inside a class -- which works fine during threading.

    I also tried looping through the tabpages on this control, and there were none, but the data in the DGV are visible during the invalidate procedure(?)

    What would cause this exception to be thrown now, when it was never thrown before?
    Last edited by pel11; Mar 28th, 2022 at 12:48 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width