Sortedlist, sorteddictionary and DatagridView

o-mheien@hdsoftware.no

Active member
Joined
Feb 6, 2007
Messages
27
Programming Experience
10+
Hi folks
I have some problems using a sortedlist or sorteddirectory as datasource on a DatagridView control. Is there a way to do this at all? Using a LIST is not a problem, but I was hoping to use a SortedList instead since its easyer to get records from that.

Regards
Ole
 
For display purposes the Collections.Generic.SortedList(Of Tkey, Tvalue).Values (which is an IList) could be used as datasource for DataGridView.
Same for Collections.SortedList.GetValueList is an IList.
 
Really? Look at the attatchemtn. There I cant get this to work. Really nice if you could manage to mod it to show me how to do this correct.

Its on button4

Regards
Ole
 

Attachments

  • Lists.zip
    58.1 KB · Views: 34
Strange, but it looks like DGV supports only collections.IList and not the Collections.Generic.Ilist(Of T), so this code works:
VB.NET:
Dim srtList As New SortedList 
srtList.Add("Person 2", New Person("0", "Nils2"))
srtList.Add("Person 1", New Person("0", "Nils1"))
Me.DataGridView1.DataSource = srtList.Values
 
Back
Top