Solved

Need Help With listview Being Populated by Tab Label Control Names in Order of First to Last

Posted on 2007-03-27
4
172 Views
Last Modified: 2012-05-05
USING VB.NET VS STUDIO 2003

Hi I have a piece of code that populates a listview and it works fine. However I notice a quirk that occurs. Let me explain.

The lv is populated by the label control names of a selected tab in another form..form16. In Form16 there are 2 tabs that I have manually created and the user can create as many other tabs as they want.

When the user created tabs populate the listview they list in the order they were created from first to last. When the manually created tabs populate the listview they list as follows:

tab 1 - last to first
tab 2 - all over the place

I checked the Tab Index numbers and they are not the problem so I am lost. Please help.

Thanks

PB

    Private Sub Form16_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim listitem As ListViewItem
        Dim ctrl As Control
        lsvTabSel.Items.Clear()
        lsvTabSel.View = View.Details
        lsvTabSel.FullRowSelect = True
        lsvTabSel.Columns.Add("Attribute", 200, HorizontalAlignment.Left)
        lsvTabSel.Columns.Add("Type", 100, HorizontalAlignment.Left)

        For Each ctrl In clsGlobals.Form2.TabControl1.SelectedTab.Controls
            If TypeOf ctrl Is Label Then
                listitem = lsvTabSel.Items.Add(ctrl.Name)
                Dim strLines() As String = ctrl.Tag.Split(vbCrLf)
                If strLines(0).Trim = "L" Then
                    listitem.SubItems.Add("Logic")
                ElseIf strLines(0).Trim = "T" Then
                    listitem.SubItems.Add("Text")
                ElseIf strLines(0).Trim = "N" Then
                    listitem.SubItems.Add("Numeric")
                ElseIf strLines(0).Trim = "A" Then
                    listitem.SubItems.Add("AutoNumber")
                ElseIf strLines(0).Trim = "D" Then
                    listitem.SubItems.Add("Date")
                End If
            End If
        Next

0
Comment
Question by:PBLack
  • 2
  • 2
4 Comments
 

Author Comment

by:PBLack
ID: 18800150
I went in and manually renumbered the index of every control. No change. I don't know what to do to fix this.

PBLack
0
 
LVL 6

Expert Comment

by:riyazthad
ID: 18800290
What is your problem, list is not poplating at all ? or not adding items from tab which user created? What about items from tab, that already there?
0
 

Author Comment

by:PBLack
ID: 18800405
No it adds fine. I want them to list in the order of the Tab Index number from lowest to highest. Currently the two manually created tabs do not list according to the order they numbered. Don't know how to do this.

PBLack
0
 
LVL 6

Accepted Solution

by:
riyazthad earned 500 total points
ID: 18801211
you can do many ways.

you can add an invisible column (width=0) and then add
 listitem = lsvTabSel.Items.Add(ctrl.TabIndex)

After adding all items you do sorting (After For Loop)
 ListView1.Sorting = SortOrder.Ascending
  ListView1.Sort()

try
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question