Question VS2010 Cascade forms, large ones in back

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,530
Location
Lansing, MI; USA
Programming Experience
10+
I've got a collection of a type of form and multiple of these can be displayed on the screen independently at the same time and now I'm wanting to add the ability to cascade these forms, but these forms can all be re-sized so it'll be very rare when they are of the same or similar size. I would like to be able to cascade them based on their present size, so the largest for is in the back and the smallest is in front. I also realize that a form could be wider than than another form but that other form is taller than the current one, in which case I would like the taller form to be considered the larger one (an arbitrary decision, I know). Here's the code I currently have that cascades them in the order they are in the collection, I just need to know how to re-order them based on their size.
VB.NET:
Private m_OpenNotes As New List (Of NoteForm)

Private Sub CascadeNotes()
    If m_OpenNotes.Count > 0I Then
        Dim LocationOffset As Integer = 15I
        For Counter As Integer = 0I To m_OpenNotes.Count - 1I
            With m_OpenNotes(Counter)
                If Counter = 0I Then
                    'Position the first note
                    .Location = New Point(LocationOffset, LocationOffset)
                Else
                    'Position this note in relation to the previous one
                    .Location = New Point( _
                        m_OpenNotes(Counter - 1I).Location.X + LocationOffset, _
                        m_OpenNotes(Counter - 1I).Location.Y + LocationOffset)
                End If
            End With
        Next Counter
    End If
End Sub
 
Dim ordered = From note In m_OpenNotes Order By note.Height Descending
 
Back
Top