Solved

vb 2010 sorting combo box with data source

Posted on 2014-01-21
6
426 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
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

803 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