Get all values from a property of IList object (as combobox do)

  • Thread starter Thread starter LG DES
  • Start date Start date
L

LG DES

Guest
Hi,

I want to do the same as combobox do when assign datasource/displaymember properties: Get all values of field/property named as .DisplayMember from .Datasource object.

In a combobox, when you assign an object (datatable, dataview, list(of ..), etc) to .Datasource, you can define 'field/property' to show in .DisplayMember). I want to do exactly the same.

Datasource is defined as 'An object that implements the IList interface or an Array. '

Then, I need to create a function that returns a list/array/whaever from Object and Displaymember

' I tried reflection, but i can obtain field/property DisplayMember
Function GetAllValues(From As Object, DisplayMember As String) As ¿IList?

Dim list As IList = CType(From, IList)

list.ToList(Displaymember)

Dim listReturn As New List()

' Obviusly, this doesnt work ;-)
For Each oItem In list
listReturn.Add oItem.Gettype().GetProperty(DisplayMember)
Next oItem


End Function

Thanks

Continue reading...
 
Back
Top