Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-03-27
4
Medium Priority
?
192 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 2000 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

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 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