I have a combo populated with:

With Me.cboOwner                            '// populate cboOwner
            .DataSource = dtMyCos
            .DisplayMember = "CoName"
        End With

DtCos datatable contains:
CoID int
CoName string

So far so good!

Then I have a second combo cboIssuer that needs to contain all the items in cboOwner
**PLUS** an additional item CoName: "Mothership"
I'm failing miserably to clone cboOwner.items to cboIssuer.items and add the additional "Mothership" item.

Any suggestions?

In case it helps, dtMyCos is filled via ExecuteReader, and in the current test database there is a row
CoID: 1
CoName: 'Mothership'
The 'Mothership' entry will **ALWAYS** be CoID = 1

Use a for loop once cboOwner has been populated. -

Dim x As Integer

For x = 0 To cboOwner.ListCount
   cboIssuer.AddItem cboOwner.Text
Next x

cboIssuer.AddItem "Mothership"

Thanks Andre,

I had already tried (a corrected-version of) that
For x = 0 To cboOwner.ListCount-1
but it didn't want to work.
Can it be to do with cboOwner using a datatable as .DataSource ???

The question is only of academic interest now.
I decided to drop the second combo and use cboOwner.Text as radiobutton1.Text and "Mothership" as radiobutton2.Text ...it makes more sense for the application this way.

Edited 6 Years Ago by izyrider: n/a

I have to apologise izyrider. I just migrated from vb6 to .net, and it seems that I still mix the codes a bit. Ignore my previous code above, it is totally incorrect.

Have a look at the following link, it covers all on list and combo box. Very nice code included as well.

http://www11.brinkster.com/notbono/vbnet.asp

LOL

No worries - I know how you feel!

I'm a touch over a year into my migration from Access-VBA to VB.NET and every day or two I bump into something that I don't know how to do (something that I can code in A-VBA using Notepad with 100% certainty that it would run first time when pasted into Access).

It's great to be a newbie again!

izy

Thats the truth. I must say, it gets damn annoying sometimes when you spend half an hour on a sub just to find out that it's all "old" school and not working in .net.

This article has been dead for over six months. Start a new discussion instead.