Inserting in to a list box. Insertions not appearing.

Oct 23 2010 6:00 PM
Hi All, 

I am trying to get the following to work: 

  TexationJobsEntities de = new TexationJobsEntities();

            var operatives = from o in de.Operatives
                             select new {o.OperativeID, o.First_Name, o.Last_Name};

            foreach (var operative in operatives)
            {
                operativesListBox.Items.Insert(operative.OperativeID, operative.First_Name + " " + operative.Last_Name);
            }

Its very weird as the list box remains empty. but the following works fine (apart from the fact that the entries are not in sync with the source database)

  TexationJobsEntities de = new TexationJobsEntities();

            var operatives = from o in de.Operatives
                             select new {o.OperativeID, o.First_Name, o.Last_Name};

            foreach (var operative in operatives)
            {
                operativesListBox.Items.Add(operative.First_Name + " " + operative.Last_Name);
            }


anyone have any ideas ?

Thanks in advnace

Regards
Ore

Answers (3)