Solved

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

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 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