?
Solved

vb 2010 sorting combo box with data source

Posted on 2014-01-21
6
Medium Priority
?
431 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
[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
  • 4
  • 2
6 Comments
 
LVL 83

Expert Comment

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

Author Comment

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

Expert Comment

by:CodeCruiser
ID: 39807583
What happens if you change

            genericList.AddRange(Desc)

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

to

            genericList.Add("Start Here")
            genericList.AddRange(Desc)
?
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:MVLIS
ID: 39807730
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
ID: 39812397
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
ID: 39826092
Thank you for replying back but I was finally able to solve on my own.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

752 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