Solved

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

Posted on 2007-03-27
4
177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 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