Text in Combobox

G

Guest

Hi All,
I am having trouble putting text in the combobox in a pocket pc app in .net.
I can populate the drop down list but I also want text in the combobox
(before an item has been selected), I could do this in eVB with:

CboMachine Number.Text = "105763"

This would be displayed in the combobox. It doesn't seem to work in .net, my
combobox is always blank until an item is selected from the combobox list by
the user, any idea's.

Thanks in advance for your help.
Roger.
 
M

Maarten Struys, eMVP

This is the default behavior of a ComboBox in the .NET CF. As a work around
you might consider first adding your entry to the combobox and immediately
afterwards setting the Text property, something like this:

CboMachineNumber.Items.Add("105763")
CboMachineNumber.Text = "105763"

In this case the item will appear in the combobox without the user having to
select it.

--
Regards,

Maarten Struys, eMVP
PTS Software bv

www.opennetcf.org | www.dotnetfordevices.com
 
S

Steven Licciardi

You can use either :

ComboBox1.SelectedIndex = 5
ComboBox1.SelectedItem = "105763"

Steven
 
G

Guest

Thanks for the help, I wanted the displayed text to be different to what is
in the list (something like "Click here to select Machine Number"), I have
thought about having a label showing the text and then making it invisible
when the combobox was clicked but I can't see that working too well if the
user dosn't actually select anything, also I thought about removing the text
from the list when the user clicked the control, but I may have the same
problem.
Anyway, if the text has to be in the list so be it - I won't loose any sleep
over it.

thanks again, Roger.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top