Solved

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

Posted on 2007-03-27
4
163 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now