|
-
Mar 24th, 2022, 11:26 AM
#1
Thread Starter
Lively Member
[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.
-
Mar 24th, 2022, 07:59 PM
#2
Re: TabPage index is invalid but visible?
Have you looked at the stack trace of the exception to see exactly where the exception is being thrown? You should always start by establishing exactly what problem it is that you're trying to solve.
-
Mar 28th, 2022, 12:48 PM
#3
Thread Starter
Lively Member
Re: TabPage index is invalid but visible?
This was resolved, since threading was being used. A delegate was applied, which resolved the tabcontrol issues.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|