Solved

vb 2010 sorting combo box with data source

Posted on 2014-01-21
6
424 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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:…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

948 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

23 Experts available now in Live!

Get 1:1 Help Now