Note that there are some explanatory texts on larger screens.

plurals
  1. POIList and SortableBindingList
    primarykey
    data
    text
    <p>is it possible to create a sortable list in a generic way from an IList?</p> <p>i have </p> <pre><code>Private Class DTO Public Property text1 As Integer Public Property text2 As String Public Property text3 As String Public Property text4 As DateTime End Class Private Function getList() As List(Of DTO) Dim l As New List(Of DTO) l.Add(New DTO With {.text1 = 1, .text2 = Nothing}) l.Add(New DTO With {.text1 = 2, .text2 = "xxx"}) l.Add(New DTO With {.text1 = 3, .text2 = "yyy"}) For i = 1 To 2000 l.Add(New DTO With {.text1 = i, .text2 = "a_" &amp; (2000 - i).ToString, .text3 = "test" &amp; i, .text4 = DateTime.Now}) Next Return l End Function Private Sub fillListSearch(Of T)(lst As SortableBindingList(Of T)) fillWithList(lst) End Sub Private Sub fillWithList(ByRef pr_list As IList) '--&gt; create a SortableBindingList of this list grd.DataSource = pr_list End Sub </code></pre> <p>I need to move the functionality from fillListSearch into fillWithList nut i don't get the way how to convert that IList into an SortableBindingList(Of T).</p> <p>Any hints? Can this be done with reflection?</p> <p>_thanks</p> <p><strong>Update</strong>: Managed to get this working</p> <pre><code>Private Sub fillWithList(ByRef pr_list As IList) Dim tList As System.Type = pr_list.GetType() Dim typeIntern = tList.GetGenericArguments()(0) Dim typeSortList As Type = GetType(SortableBindingList(Of )) Dim typeArgs() As Type = {typeIntern} Dim constructed As Type = typeSortList.MakeGenericType(typeArgs) Dim sortedList As Object = Activator.CreateInstance(constructed, pr_list) grd.DataSource = sortedList </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload