dimanche 29 mars 2015

How To Make An iBindingList Powershell

I am working on an UI in Powershell and have ran into a roadblock. I queried a computers win32_service and put the output into a Datagridview by using an ArrayList and I would like to be able to sort the output. I learned after the fact that I cannot call Datagridview.Sort() when I use a list as a datasource. The error tells me that I need an iBindingList in order to sort. This is where I'm at



$services = get-wmiobject win32_service
$datagrid = new-object system.windows.forms.datagridview
$databinding = new-object system.componentmodel.ibindinglist
$databinding.add($services)
$datagrid.datasource = $databinding


this will error with: "new-object: constructor not found. cannot find an appropriate constructor for type system.componentmodel.ibindinglist"


I can't really find any information about iBindingList for powershell on the internet. Everything I've seen so far has been about c# or c++ and it seems pretty easy in those to declare an iBindingList. Maybe there is an even better way than an iBindingList, any help is appreciated. Thank you!


Aucun commentaire:

Enregistrer un commentaire