I am trying to use a WInforms BindingSource in PowerShell but I am having no success. A statement such as:
$Bs = New-Object System.Windows.Forms.BindingSource
$Bs | gm | ft
results in:
gm : You must specify an object for the Get-Member cmdlet.........
which seems odd. Nevertheless, although it is not an object I can assign values to its properties. For example,
$Bs.AllowNew = $TRUE
$Bs.DataSource = $Data
$Bs.Count
works. This is the first and only WinForms class I have used that has behaved in this way. The count value is correct so if $Data contains 4 items, $Bs.Count reports 4.
If I do something like: (I have created a form)
$Dg = New-Object System.Windows.Forms.DataGridView
$Dg.DataSource = $Bs
nothing is displayed. The $Data variable mentioned earlier is an arraylist with a few strings in it. This example (usually written in C#) is commonly used in many web pages where people demonstrate how to use BindingSource with DataGridView and some use arraylists as well so I have assumed that this is a valid combination but perhaps it isn't.
Oddly, if I assign it directly to $Dg.DataSource I don't get the strings displayed; I get the lengths of each string instead but that's another story I suppose.
If anyone has any ideas about how to make BindingSource work I would be very grateful.
Best wishes....
Colin Bruce