Groups | Blog | Home
all groups > dotnet compact framework > february 2006 >

dotnet compact framework : combobox and dataset indexOf



merco
2/14/2006 12:03:43 AM
Hi, i'm populating a combobox small datas from a Dataset.
Dim Ds As DataSet
Ds = GetDS("Select * from Utenti")
Cb.Items.Clear()
Cb.DataSource = Ds.Tables(0)
Cb.DisplayMember = "Descrizione"
Cb.ValueMember = "Codice"

It's a simple "Users" table with ID (codice) and description
(descrizione).
Is there a way to pre-select an item by it's code without cycling for
all items in combobox ?

I've tried , with no success, indexof ,passing only a string type
parameter (the code)...

thanks
Fabien
2/14/2006 1:52:35 AM
Hi,

in C# you can use the attribute Item like this, I think tou can do the
same thing in VB :

Cb.Text =3D Cb.Item[number of the Item you want display].ToString();

BR

Fabien Decret

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/

merco a =E9crit :

[quoted text, click to view]
merco
2/14/2006 3:08:20 AM
ok, but i don't know the "number of the Item you want display" i only
know the code..."ID"
Joseph Byrns
2/14/2006 2:20:06 PM
Does the following not work?

ComboBox1.SelectedValue = "The Codice you want here" //(assuming codice is a
string)


[quoted text, click to view]

AddThis Social Bookmark Button