Using SortedList as a listboxes datasource

Hi All,

I have been playing with the datasource members of listboxes and have been trying them with different System.Collections. I cannot seem to get them to work with a SortedList. I am not usre if there is something that I am doing wrong, or you simple can't do it using the .NET CF 2.0. A possible reason could be because of the the key/value pair and no DataKeyValue member.

Any ideas on what could be happening and how it can be fixed

Here is an example of what was done

private SortedList<string, string> slWaypoints;

slWaypoints = new SortedList<string, string>();

slWaypoints.Add("ABCALPHA", " 123456");

slWaypoints.Add("DEFALPHA", " 123456");

slWaypoints.Add("GHIALPHA", " 123456");

slWaypoints.Add("JKLALPHA", " 123456");

slWaypoints.Add("MNOALPHA", " 123456");

slWaypoints.Add("PQRALPHA", " 123456");

slWaypoints.Add("STUALPHA", " 123456");

slWaypoints.Add("VWXALPHA", " 123456");

slWaypoints.Add("YZ1ALPHA", " 123456");

this.lbWaypoint.DataSource = slWaypoints;



Answer this question

Using SortedList as a listboxes datasource

  • Matrixchyah

    DataSource has to implement at IList interface and SortedList does not so it can’t be used as data source.



  • Using SortedList as a listboxes datasource