Unexpected Index Change.
Unexpected Index Change.
Unexpected Index Change.
Unexpected Index Change.
Unexpected Index Change.
Unexpected Index Change. Unexpected Index Change. Unexpected Index Change. Unexpected Index Change. Unexpected Index Change. Unexpected Index Change. Unexpected Index Change. Unexpected Index Change.
Unexpected Index Change. Unexpected Index Change.
Unexpected Index Change.
Go Back  Xtreme Visual Basic Talk > > > Unexpected Index Change.


Reply
 
Thread Tools Display Modes
  #1  
Old 06-02-2017, 02:19 AM
Goggy's Avatar
Goggy Goggy is offline
Contributor
 
Join Date: Sep 2005
Location: Enschede,The Netherlands
Posts: 670
Default Unexpected Index Change.


Could any one hint me in the right direction why the code shown below, (not every time, but once in a while) would change the index of the controls in the controlcollection?

Code:
    Public Overrides Function Layout(container As Object, layoutEventArgs As LayoutEventArgs) As Boolean
        Parent = TryCast(container, TabControl)
        If Parent IsNot Nothing Then
            For I As Integer = 0 To Parent.Controls.Count - 1
                Tp = TryCast(Parent.Controls.Item(I), TabPage)
                If Tp IsNot Nothing Then
                    With Tp
                        .Header.Bounds = New Rectangle(I * Parent.HeaderWidth.ToInteger, 0, Parent.HeaderWidth.ToInteger, Parent.HeaderHeight.ToInteger)
                        .Visible = Tp.Header.IsSelected
                    End With
                End If
            Next
        End If
        Return False
    End Function
__________________
As finishing touch, god created the Dutch!

utterly useless, but always trying to help
Reply With Quote
  #2  
Old 06-05-2017, 03:13 PM
passel's Avatar
passelUnexpected Index Change. passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

I don't know specifically, but I've found that the order the controls are in the forms collection depend on the order they are written in the .frm file. Since the .frm file is updated with code quite often, so re-written quite often, the order of things in the file may change.
For instance, it seems quite often that I add controls to the form and save the project, that the controls are written to the file in the reverse order that I added them, the first time. It may stay that way for a while, but further edits to the form do seem to sometimes cause the order in the .frm file to change.
VB doen't care about the order that controls are added to the collection and you shouldn't rely on the controls being in a particular order either.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 06-06-2017, 01:57 AM
Goggy's Avatar
Goggy Goggy is offline
Contributor
 
Join Date: Sep 2005
Location: Enschede,The Netherlands
Posts: 670
Default

Thank you Passel for this clear answer.
__________________
As finishing touch, god created the Dutch!

utterly useless, but always trying to help
Reply With Quote
Reply

Tags
function, isnot, parent, layouteventargs, change, index, integer, .visible, tp.header.isselected, false, return, rectanglei, tabcontrol, tabpage, .header.bounds, parent.controls.count, object, code, shown, direction, hint, time, overrides, public, layoutcontainer


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Unexpected Index Change.
Unexpected Index Change.
Unexpected Index Change. Unexpected Index Change.
Unexpected Index Change.
Unexpected Index Change.
Unexpected Index Change. Unexpected Index Change. Unexpected Index Change. Unexpected Index Change. Unexpected Index Change. Unexpected Index Change. Unexpected Index Change.
Unexpected Index Change.
Unexpected Index Change.
 
Unexpected Index Change.
Unexpected Index Change.
 
-->