Solved

vb 2010 sorting combo box with data source

Posted on 2014-01-21
6
422 Views
Last Modified: 2014-02-01
I have a combo box that has a data source as a one dimensional array because I am using Retrieve list to get data from an as400 file.  I need to add an item so I converted it to a list. Now I need to add that item at the beginning or reverse the list. I am able to accomplish the above but when I insert, sort or reverse the list the combo box will display the member and value instead of just the Display member. If I take the insert, sort or reverse out it will go back to just displaying the member. If I use the add method on the list it just populates the list at the end, as expected. But with the add display member is the only thing that appears in the combo box.  I have added an image below for a better understanding.


Dim location As String = "I"
            Dim columns = M_METPCols.M_ETDS + M_METPCols.M_ETCD

            'populate combo box in datagridview
            Dim cboDescription As New DataGridViewComboBoxColumn
            CBDescription.Tag = M_METPCols.M_ETDS
            Dim Desc = TroubleContext.M_METP.RetrieveList(columns, M_METPExprs.M_EARL = "I")
         *******   below is were I am trying to sort ********************
            Dim genericList As New List(Of Object)
            genericList.AddRange(Desc)

            genericList.Add("Start Here")
            genericList.Reverse()

            CBDescription.DisplayMember = "M_ETDS"
            CBDescription.ValueMember = "M_ETCD"

            CBDescription.DataSource = genericList



            'Retrieve line number with signon name
            MstLine = New DataContext(True)
            Dim LineNumber = MstLine.M_MSTLIN.RetrieveItem(M_MSTLINCols.M_EMWC, M_MSTLINExprs.USER = cf.UserName)


            'populate item combo box with the engine component issue
            BOM = New DataContext(True)
            BOM.Connect(cf.Server, cf.PortNumber, cf.Partition, cf.UserName, cf.Password)
            Dim BOMList = BOM.M_MIIP.RetrieveList(M_MIIPExprs.M_EMWC = LineNumber.ToString)

            Dim DESCS
            For a = 0 To BOMList.Count - 1
                DESCS = BOMList(a).IMSD10
                CBITEM.Items.Add(DESCS)
            Next

        End If
    End Sub
Capture.PNG
0
Comment
Question by:MVLIS
  • 4
  • 2
6 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
Can you show a screenshot with the combobox open? For both cases please.
0
 

Author Comment

by:MVLIS
Comment Utility
Thank you so much, screen shots are below.
screen.jpg
0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
What happens if you change

            genericList.AddRange(Desc)

            genericList.Add("Start Here")
            genericList.Reverse()

to

            genericList.Add("Start Here")
            genericList.AddRange(Desc)
?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:MVLIS
Comment Utility
Same issue, but I think something like
genericList.add(new OBJECT{M_ETDS=""Start Here"", M_ETCD=""5""})  needs to happen.

not sure what the OBJECT is though, I tried New genericList but doesn't work.
0
 

Accepted Solution

by:
MVLIS earned 0 total points
Comment Utility
After several hours finally got it.



'populate combo box in datagridview
            Dim cboDescription As New DataGridViewComboBoxColumn
            CBDescription.Tag = M_METPCols.M_ETDS
            Dim Desc = TroubleContext.M_METP.RetrieveList(columns, M_METPExprs.M_EARL = "I")
            Dim genericList As New List(Of Object)
            genericList.AddRange(Desc)

            genericList.Add(New M_METP())
            Dim c = genericList.Count()
            genericList.Insert(genericList.Count() - 1, New M_METP() With {.M_ETDS = "insert here", .M_ETCD = 5})
            genericList.Reverse()

            CBDescription.DisplayMember = "M_ETDS"
            CBDescription.ValueMember = "M_ETCD"

            CBDescription.DataSource = genericList
0
 

Author Closing Comment

by:MVLIS
Comment Utility
Thank you for replying back but I was finally able to solve on my own.
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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
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.

771 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

11 Experts available now in Live!

Get 1:1 Help Now