3
Answers

Inserting in to a list box. Insertions not appearing.

Paul Chambers

Paul Chambers

14y
1.6k
1
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)