I have a combobox that pulls a list of values from a database. When a new entry is entered I want an entry in the combobox to read "New record". However, from what I have seen I can only insert and object, such as a DataRow, into the combobox. Is there anyway I can convert a string to to a DataRow, or some other object and insert it in to the combobox? I know there is I am just rusty on my vb.

Can you post the code you have? That would help to see what you are doing wrong.

Hi
I think you are looking for a data item....

e.g.

sub populatecomboboxManually ()
dim MyCombo as New Combobox

'do whatever you need to get your data.....
for i = 1 to 10
'New DataItem(ID (is not displayed) , Value (is displayed))
MyCombo.items.add(New DataItem(i,MyValue))
Next
end sub

sub readvaluefromcombo()
dim myDi as DataItem
dim myID as integer 'can of course be anything you want
dim myValue as String 'as above
myDI = MyCombo.SelectedItem
MyID = DI.ID
MyValue = DI.Value
end sub

As I said you can manually populate your dataitem. I usually use an integer for the ID..

Or you can read in values from a database and use something like primary key for ID and whatever field you want for value. As long as the ID is unique it will work. Just because you have to put ID and values into the dataitem doesn't mean you have to use both in your code.

That will probably work. All I wanted to do is put a place holder there as soon as the user starts entering a new record. As I have it right now it just refreshes the combobox after the new data is entered. I think that will actually be the better way to do it anyway. Thanks for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.