tags:

views:

105

answers:

1

hi

I have this code :

    public static List<string> MyTable = new List<string>();

dsView = new DataSet();

adp = new SqlCeDataAdapter("SELECT DISTINCT Fname FROM MEN", Conn);

adp.Fill(dsView, "MEN");

adp.Dispose();

foreach (DataRow R in dsView.Tables["MEN"].Rows)

GG.Add( R["Fname"].ToString());

how to Bind it to ComboBox ?

thank's in advance

+4  A: 

You just set the ComboBox's DataSource equal to the List.

comboBox1.DataSource = MyTable;

If you use a System.ComponentModel.BindingList instead of a List then changes to the list will be sent to the ComboBox

Also should your last line:

GG.Add( R["Fname"].ToString());

be

MyTable.Add( R["Fname"].ToString());
JDunkerley
http://stackoverflow.com/questions/1440244/how-do-you-refresh-a-combo-box-item-in-place
Jon Seigel
thank's for the help,what takes more memory, bind combobox to dataset or List<> ?
Gold