none
Databinding problem ?

    Question

  • Hello everyone

    I have a little problem with a datagrid.

    On a windows XP this code is working perfectly (powershell v2)

    function Get-DiskSpace{
      Param(
        [String]$TargetComputer = "."
      )
        $array = New-Object System.Collections.ArrayList
        $Script:DiskSpace = Get-WMIObject  -ComputerName $TargetComputer Win32_LogicalDisk `
        | select VolumeName, Name, DriveType, @{n='Size(Gb)' ;e={"{0:n2}" -f ($_.size/1gb)}},@{n='FreeSpace(Gb)';e={"{0:n2}" -f ($_.freespace/1gb)}}, @{n='PercentFree';e={"{0:n2}" -f ($_.freespace/$_.size*100)}}
        $array.AddRange($DiskSpace)
        $dataGrid1.DataSource = $array #<--- HERE !!
        $form1.refresh()
    }

    but on my Win7 (powershell V3, and i tried it with -version 2.0) i keep getting error messages :

    FullyQualifiedErrorId : Complex DataBinding accepts as a data source either an IList or an IListSource

    and the worst is that i have a timer, and when i run the script for the first time the timer is working perfectly, but when i run it a second time, it's like the first timer didnt stop... i have to close the my powershell and then run it again... (If you can help me with the first question it'll be very helpful!)

    samedi 3 mars 2012 17:23

Réponses

  • doesnt work with PF CE

    You havve an issue with yorr installation of PoswerShell 3.  You should install the beta that was just released two days ago.

    You have not told us what architecture you are using.


    ¯\_(ツ)_/¯

    • Marqué comme réponse TonQ lundi 5 mars 2012 17:39
    dimanche 4 mars 2012 18:00

Toutes les réponses

  • Can you post the full code here? It will be easier to see the full code so we can run it and troubleshoot it.

    Boe Prox

    Please remember to mark the best solution as the answer using Mark as Answer. If you find a solution to be helpful, please use Vote as Helpful.

    Looking for a script? Check out the Script Repository
    Need a script written for you? Submit a request at the Script Request Page

    samedi 3 mars 2012 17:55
  • yep !

    same code as yesterday :) it just wont work on my personnal computer, when it should ! (btw the autosize = $true doesnt work :p) thx for your help!

    function GenerateForm {
      Param(
        [String]$Computer1 = "."
      )
    
    #region Import the Assemblies
    [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
    [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
    #endregion
    
    #region Generated Form Objects
    $form1 = New-Object System.Windows.Forms.Form
    $dataGrid1 = New-Object System.Windows.Forms.DataGrid
    $textBox1 = New-Object System.Windows.Forms.TextBox
    $button2 = New-Object System.Windows.Forms.Button
    $button1 = New-Object System.Windows.Forms.Button
    $timer1 = New-Object System.Windows.Forms.Timer
    $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
    #endregion Generated Form Objects
    
    #----------------------------------------------
    #Generated Event Script Blocks
    #----------------------------------------------
    #Provide Custom Code for events specified in PrimalForms.
    #Provide Custom Code for events specified in PrimalForms.
    $LoadForm=
    {
        get-diskspace -TargetComputer $Computer1
    }
    $button1_OnClick= 
    {
        $Form1.Close()
    }
    $button2_OnClick= 
    {
        $b = $textBox1.text
        $textBox1.Clear()
        If(!($b.length -eq 0)){
            write-host "b contient: $b $b"
            New-Monitor-Form -ParamComputer $b
        }
    }
    
    $Update= 
    {
        $a = date
        write-host $Computer1 " " $a
        get-diskspace -TargetComputer $Computer1
    }
    
    $OnLoadForm_StateCorrection=
    {#Correct the initial state of the form to prevent the .Net maximized form issue
    	$form1.WindowState = $InitialFormWindowState
    }
    
    #----------------------------------------------
    #region Generated Form Code
    $form1.AutoSize = $True
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 164
    $System_Drawing_Size.Width = 467
    $form1.ClientSize = $System_Drawing_Size
    $form1.DataBindings.DefaultDataSourceUpdateMode = 0
    $form1.Name = "form1"
    $form1.Text = $Computer1
    $form1.add_Load($LoadForm)
    
    $dataGrid1.CaptionBackColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    $dataGrid1.CaptionFont = New-Object System.Drawing.Font("Microsoft Sans Serif",1,1,3,1)
    $dataGrid1.CaptionVisible = $False
    $dataGrid1.DataBindings.DefaultDataSourceUpdateMode = 0
    $dataGrid1.DataMember = ""
    $dataGrid1.HeaderForeColor = [System.Drawing.Color]::FromArgb(255,0,0,0)
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 10
    $System_Drawing_Point.Y = 12
    $dataGrid1.Location = $System_Drawing_Point
    $dataGrid1.Name = "dataGrid1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 109
    $System_Drawing_Size.Width = 445
    $dataGrid1.Size = $System_Drawing_Size
    $dataGrid1.TabIndex = 4
    
    $form1.Controls.Add($dataGrid1)
    
    $textBox1.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 111
    $System_Drawing_Point.Y = 133
    $textBox1.Location = $System_Drawing_Point
    $textBox1.Name = "textBox1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 20
    $System_Drawing_Size.Width = 123
    $textBox1.Size = $System_Drawing_Size
    $textBox1.TabIndex = 3
    
    $form1.Controls.Add($textBox1)
    
    
    $button2.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 12
    $System_Drawing_Point.Y = 130
    $button2.Location = $System_Drawing_Point
    $button2.Name = "button2"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 93
    $button2.Size = $System_Drawing_Size
    $button2.TabIndex = 2
    $button2.Text = "Monitor Server"
    $button2.UseVisualStyleBackColor = $True
    $button2.add_Click($button2_OnClick)
    
    $form1.Controls.Add($button2)
    
    
    $button1.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 361
    $System_Drawing_Point.Y = 130
    $button1.Location = $System_Drawing_Point
    $button1.Name = "button1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 94
    $button1.Size = $System_Drawing_Size
    $button1.TabIndex = 1
    $button1.Text = "Close"
    $button1.UseVisualStyleBackColor = $True
    $button1.add_Click($button1_OnClick)
    
    $form1.Controls.Add($button1)
    
    $timer1.Enabled = $True
    $timer1.Interval = 15000
    $timer1.add_Tick($Update)
    
    #endregion Generated Form Code
    
    #Save the initial state of the form
    $InitialFormWindowState = $form1.WindowState
    #Init the OnLoad event to correct the initial state of the form
    $form1.add_Load($OnLoadForm_StateCorrection)
    #Show the Form
    $form1.ShowDialog()| Out-Null
    
    } #End Function
    
    #Call the Function
    function Get-DiskSpace{
      Param(
        [String]$TargetComputer = "."
      )
        $array = New-Object System.Collections.ArrayList
        #AVEC LE WHERE OBJECT DRIVETYPE 3 ON MONITORE UNIQUEMENT LES DISQUE DUR, DONC PAS DE CD, NI DE CLES USB
        $Script:DiskSpace = Get-WMIObject  -ComputerName $TargetComputer Win32_LogicalDisk `
        | select VolumeName, drivetype, Name, @{n='Size (Gb)' ;e={"{0:n2}" -f ($_.size/1gb)}},@{n='FreeSpace(Gb)';e={"{0:n2}" -f ($_.freespace/1gb)}}, @{n='PercentFree';e={"{0:n2}" -f ($_.freespace/$_.size*100)}} `
        | Where-Object {$_.DriveType -eq 3}
        $array.AddRange($DiskSpace)
        $dataGrid1.DataSource = $array
        $form1.refresh()
    }
    
    function New-Monitor-Form{
      Param(
        [String]$ParamComputer = "."
      )
        $pi = New-Object system.Diagnostics.ProcessStartInfo
        $pi.FileName = "powershell.exe"
        $pi.Arguments = "-windowstyle hidden -noprofile -command D:\SCRIPTING\SCRIPT_POWERSHELL\get-diskspace-form-4.ps1 $ParamComputer"
        [system.Diagnostics.Process]::Start($pi) 
    }
    
    if(!($args.count -eq 0)){
        GenerateForm -Computer1 $args.get(0)
    }else{
        GenerateForm
    }
    

    samedi 3 mars 2012 17:58
  • It would be much better if you posted the contents of the PFF file.  We cannot edit this script very easily due to its size.


    ¯\_(ツ)_/¯

    samedi 3 mars 2012 18:52
  • uh?

    i just create the form with PF, then i paste the code in powershell ise, and add what i want. I dont save the form in PF... :/

    the problem is in the Get-DiskSpace function when i do this :

    $dataGrid1.DataSource = $array

    samedi 3 mars 2012 19:02
  • Your assumption about how to load a datagrid in WIndows 7 looks wrong.

    Manual testing form the command line throws errors.

    Start by changing this line.

        $array = New-Object System.Collections.ArrayList
        $DiskSpace = Get-WMIObject  -ComputerName $TargetComputer Win32_LogicalDisk -filter 'DriveType=3'  |
             select VolumeName, drivetype, Name, @{n='Size (Gb)' ;e={"{0:n2}" -f ($_.size/1gb)}},@{n='FreeSpace(Gb)';e={"{0:n2}" -f ($_.freespace/1gb)}}, @{n='PercentFree';e={"{0:n2}" -f ($_.freespace/$_.size*100)}} 
        $array.AddRange(@($DiskSpace))
        $dataGrid1.DataSource = $array

    This prevents single values from being an error.

    You have also hardcoded the script name into the file which makes testing a pain in the neck.

    With those changes the script works for me on Windows 7 PowerShell V3..

    Timers should be set within the form as a timer control.  Each timer needs to refresh its own form.

    The timers do not work as intended on any system or version of PowerSHell as far as I can tell.


    ¯\_(ツ)_/¯



    • Modifié jrv samedi 3 mars 2012 19:18
    samedi 3 mars 2012 19:11
  • Yes i know ... about the hardcoded name ... i'm testing sorry for the inconvenience ...

    anyway this doesnt work either :/

    same error.

    $DiskSpace = @(Get-WMIObject  -ComputerName $TargetComputer Win32_LogicalDisk -filter 'DriveType=3'  |
             select VolumeName, drivetype, Name, @{n='Size (Gb)' ;e={"{0:n2}" -f ($_.size/1gb)}},@{n='FreeSpace(Gb)';e={"{0:n2}" -f ($_.freespace/1gb)}}, @{n='PercentFree';e={"{0:n2}" -f ($_.freespace/$_.size*100)}} )

    i tried this too, same result

    samedi 3 mars 2012 19:19
  • You need to tell us what your error is.

    What OS and what version of PowerShell it works on.

    Please fix it this way:

    $Script:DiskSpace=Get-WMIObject  -ComputerName $TargetComputer Win32_LogicalDisk -filter 'DriveType=3'  |
             select VolumeName, drivetype, Name, @{n='Size (Gb)' ;e={"{0:n2}" -f ($_.size/1gb)}},@{n='FreeSpace(Gb)';e={"{0:n2}" -f ($_.freespace/1gb)}}, @{n='PercentFree';e={"{0:n2}" -f ($_.freespace/$_.size*100)}}

    $array.AddRange(@($Script:DiskSpace))


    ¯\_(ツ)_/¯

    samedi 3 mars 2012 19:26
  • I modified the way you told me : same error

    I recreated a form, with a datagrid and no timer and just a button to fill the datagrid. When i press the  button the function is called and the error is the same :

    Complex DataBinding accepts as a data source either an IList or an IListSource
    At C:\Users\Lx\Desktop\scripts\test-datagrid.ps1:108 char:5
    +     $dataGrid1.DataSource = $array
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OperationStopped: (:) [], ArgumentException
        + FullyQualifiedErrorId : Complex DataBinding accepts as a data source eit
       her an IList or an IListSource.

    Windows 7 + Powershell V 3

    samedi 3 mars 2012 19:39
  • You need to inspect the contents of the array.  It appears to be null.

    You cannot use PowerShellIse for this.  YOu must test with PowerShell.

    You are creating an array: $array = New-Object System.Collections.ArrayList

    Tis is an Ilist object.  The earlier werro canm e from assigning a singleton using AddRange.  Adding ab array wrapper prevents this.  Itf there is no error on AddRange then AddRange is adding a numm.

    You also need to be sure you have installed all dotNet service packs and patches.


    ¯\_(ツ)_/¯


    • Modifié jrv samedi 3 mars 2012 19:58
    samedi 3 mars 2012 19:55
  • i added after the get-wmi

    if($array -eq $null){write-host "array est null"}

    no messae is returned

    i tried this in a console

        $array = New-Object System.Collections.ArrayList
        $Script:DiskSpace=Get-WMIObject -ComputerName . Win32_LogicalDisk -filter 'DriveType=3' | select VolumeName, drivetype, Name, @{n='Size (Gb)' ;e={"{0:n2}" -f ($_.size/1gb)}},@{n='FreeSpace(Gb)';e={"{0:n2}" -f ($_.freespace/1gb)}}, @{n='PercentFree';e={"{0:n2}" -f ($_.freespace/$_.size*100)}}
        $array.AddRange(@($Script:DiskSpace))

    $array

    and it works ...

    samedi 3 mars 2012 20:04
  • Hardcode computer name for testing.

    I have to go.  I will be back in about an hour.


    ¯\_(ツ)_/¯

    samedi 3 mars 2012 20:07
  • Here:  I just generated a simple form with on grid and one button. I then added the followign to teh button.  No other changes to the form.  It works without issue on Win7 PosH 3.

    Added code:

    $TargetComputer=$env:COMPUTERNAME
    $array = New-Object System.Collections.ArrayList
    	    $DiskSpace = Get-WMIObject  -ComputerName $TargetComputer Win32_LogicalDisk -filter 'DriveType=3'  | 
    	         select VolumeName, drivetype, Name, @{n='Size (Gb)' ;e={"{0:n2}" -f ($_.size/1gb)}},@{n='FreeSpace(Gb)';e={"{0:n2}" -f ($_.freespace/1gb)}}, @{n='PercentFree';e={"{0:n2}" -f ($_.freespace/$_.size*100)}}
    $array.AddRange(@($DiskSpace))
    [System.Windows.Forms.MessageBox]::Show("Count: $($array.Count)")
    $dataGrid1.DataSource = $array

    I did not add or change any other element of the form.  Just add that code to the button click event.

    Here is the complete forms codeas PowerSHell code.

    #------------------------------------------------------------------------
    # Source File Information (DO NOT MODIFY)
    # Source ID: 0a3e5a76-cfbe-4b58-9249-017887ae9b20
    # Source File: C:\Documents and Settings\xxxxxx\My Documents\SAPIEN\PrimalForms 2011\Files\Demo-GridReresh.pff
    #------------------------------------------------------------------------
    #========================================================================
    # Code Generated By: SAPIEN Technologies, Inc., PrimalForms 2011 v2.0.10
    # Generated On: 3/3/2012 4:13 PM
    # Generated By:  
    # Organization:  
    #========================================================================
    #----------------------------------------------
    #region Application Functions
    #----------------------------------------------
    function OnApplicationLoad {
    	#Note: This function is not called in Projects
    	#Note: This function runs before the form is created
    	#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
    	#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
    	#Important: Form controls cannot be accessed in this function
    	#TODO: Add snapins and custom code to validate the application load
    	
    	return $true #return true for success or false for failure
    }
    function OnApplicationExit {
    	#Note: This function is not called in Projects
    	#Note: This function runs after the form is closed
    	#TODO: Add custom code to clean up and unload snapins when the application exits
    	
    	$script:ExitCode = 0 #Set the exit code for the Packager
    }
    #endregion Application Functions
    #----------------------------------------------
    # Generated Form Function
    #----------------------------------------------
    function Call-Demo-GridReresh_pff {
    	#----------------------------------------------
    	#region Import the Assemblies
    	#----------------------------------------------
    	[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
    	[void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
    	[void][reflection.assembly]::Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
    	[void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
    	[void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
    	[void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
    	[void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
    	#endregion Import Assemblies
    	#----------------------------------------------
    	#region Generated Form Objects
    	#----------------------------------------------
    	[System.Windows.Forms.Application]::EnableVisualStyles()
    	$form1 = New-Object System.Windows.Forms.Form
    	$button1 = New-Object System.Windows.Forms.Button
    	$datagrid1 = New-Object System.Windows.Forms.DataGrid
    	$buttonOK = New-Object System.Windows.Forms.Button
    	$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
    	#endregion Generated Form Objects
    	#----------------------------------------------
    	# User Generated Script
    	#----------------------------------------------
    	
    	
    	
    	
    	
    	
    	$FormEvent_Load={
    		#TODO: Initialize Form Controls here
    		
    	}
    	
    	
    	$button1_Click={
    		$TargetComputer=$env:COMPUTERNAME
    	    $array = New-Object System.Collections.ArrayList
    	    $DiskSpace = Get-WMIObject  -ComputerName $TargetComputer Win32_LogicalDisk -filter 'DriveType=3'  | 
    	         select VolumeName, drivetype, Name, @{n='Size (Gb)' ;e={"{0:n2}" -f ($_.size/1gb)}},@{n='FreeSpace(Gb)';e={"{0:n2}" -f ($_.freespace/1gb)}}, @{n='PercentFree';e={"{0:n2}" -f ($_.freespace/$_.size*100)}}
    	    $array.AddRange(@($DiskSpace))
    		[System.Windows.Forms.MessageBox]::Show("Count: $($array.Count)")
    	    $dataGrid1.DataSource = $array
    	}
    	
    	# --End User Generated Script--
    	#----------------------------------------------
    	#region Generated Events
    	#----------------------------------------------
    	
    	$Form_StateCorrection_Load=
    	{
    		#Correct the initial state of the form to prevent the .Net maximized form issue
    		$form1.WindowState = $InitialFormWindowState
    	}
    	
    	$Form_Cleanup_FormClosed=
    	{
    		#Remove all event handlers from the controls
    		try
    		{
    			$button1.remove_Click($button1_Click)
    			$form1.remove_Load($FormEvent_Load)
    			$form1.remove_Load($Form_StateCorrection_Load)
    			$form1.remove_FormClosed($Form_Cleanup_FormClosed)
    		}
    		catch [Exception]
    		{ }
    	}
    	#endregion Generated Events
    	#----------------------------------------------
    	#region Generated Form Code
    	#----------------------------------------------
    	#
    	# form1
    	#
    	$form1.Controls.Add($button1)
    	$form1.Controls.Add($datagrid1)
    	$form1.Controls.Add($buttonOK)
    	$form1.AcceptButton = $buttonOK
    	$form1.ClientSize = New-Object System.Drawing.Size(838,314)
    	$form1.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation 
    	$form1.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog 
    	$form1.MaximizeBox = $False
    	$form1.MinimizeBox = $False
    	$form1.Name = "form1"
    	$form1.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen 
    	$form1.Text = "Form"
    	$form1.add_Load($FormEvent_Load)
    	#
    	# button1
    	#
    	$button1.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation 
    	$button1.Location = New-Object System.Drawing.Point(751,181)
    	$button1.Name = "button1"
    	$button1.Size = New-Object System.Drawing.Size(75,23)
    	$button1.TabIndex = 2
    	$button1.Text = "button1"
    	$button1.UseVisualStyleBackColor = $True
    	$button1.add_Click($button1_Click)
    	#
    	# datagrid1
    	#
    	$datagrid1.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation 
    	$datagrid1.DataMember = ""
    	$datagrid1.HeaderForeColor = [System.Drawing.Color]::FromArgb(255,0,0,0)
    	$datagrid1.Location = New-Object System.Drawing.Point(12,12)
    	$datagrid1.Name = "datagrid1"
    	$datagrid1.Size = New-Object System.Drawing.Size(677,276)
    	$datagrid1.TabIndex = 1
    	#
    	# buttonOK
    	#
    	$buttonOK.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right 
    	$buttonOK.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation 
    	$buttonOK.DialogResult = [System.Windows.Forms.DialogResult]::OK 
    	$buttonOK.Location = New-Object System.Drawing.Point(751,279)
    	$buttonOK.Name = "buttonOK"
    	$buttonOK.Size = New-Object System.Drawing.Size(75,23)
    	$buttonOK.TabIndex = 0
    	$buttonOK.Text = "OK"
    	$buttonOK.UseVisualStyleBackColor = $True
    	#endregion Generated Form Code
    	#----------------------------------------------
    	#Save the initial state of the form
    	$InitialFormWindowState = $form1.WindowState
    	#Init the OnLoad event to correct the initial state of the form
    	$form1.add_Load($Form_StateCorrection_Load)
    	#Clean up the control events
    	$form1.add_FormClosed($Form_Cleanup_FormClosed)
    	#Show the Form
    	return $form1.ShowDialog()
    } #End Function
    #Call OnApplicationLoad to initialize
    if((OnApplicationLoad) -eq $true)
    {
    	#Create the form
    	Call-Demo-GridReresh_pff | Out-Null
    	#Perform cleanup
    	OnApplicationExit
    }


    ¯\_(ツ)_/¯

    samedi 3 mars 2012 21:19
  • Here is the full PFF demo file.  Save it as a PFF extension and as UTF-8 encoding.  This will let you see how all of the setting look in the designer.

    http://www.designedsystemsonline.com/upload/demo-gridrefresh.txt

    I have another demo with timers and autosize on columns using DataGridView.  I have tested it on WIndows 7 PowerShell 3.0 and it works as expected.


    ¯\_(ツ)_/¯

    samedi 3 mars 2012 22:37
  • alright. I tested your code.I see the message  returned by the count

    [System.Windows.Forms.MessageBox]::Show("Count: $($array.Count)")

    the count is 2 .

    then, same bug

    Complex DataBinding accepts as a data source either an IList or an IListSource.
    At C:\Users\Lx\Desktop\scripts\test-forum.ps1:80 char:6
    +         $dataGrid1.DataSource = $array
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OperationStopped: (:) [], ArgumentException
        + FullyQualifiedErrorId : Complex DataBinding accepts as a data source either an IList or an IListSource.

    btw, thanks for the help, and sorry for my english ... i'm frencg

    dimanche 4 mars 2012 16:04
  • by "the count is 2" i mean the array is not empty
    dimanche 4 mars 2012 16:14
  • doesnt work with PF CE
    dimanche 4 mars 2012 16:15
  • ok i tried this : this does work

    $dataGrid1.DataSource = @("Server1", "Server","Server3")

    this doesnt (hash table) :

    $dataGrid1.DataSource = @{“John Doe” = 112233; “Dave Davis” = 223344; “Justine Smith” = 334455}

    behhhhh

    dimanche 4 mars 2012 16:47
  • doesnt work with PF CE

    You havve an issue with yorr installation of PoswerShell 3.  You should install the beta that was just released two days ago.

    You have not told us what architecture you are using.


    ¯\_(ツ)_/¯

    • Marqué comme réponse TonQ lundi 5 mars 2012 17:39
    dimanche 4 mars 2012 18:00
  • ok i tried this : this does work

    $dataGrid1.DataSource = @("Server1", "Server","Server3")

    this doesnt (hash table) :

    $dataGrid1.DataSource = @{“John Doe” = 112233; “Dave Davis” = 223344; “Justine Smith” = 334455}

    behhhhh

    That usually means you are missing patches for either Net 3.5 or Net 4.0.


    ¯\_(ツ)_/¯

    dimanche 4 mars 2012 18:01
  • Alright !

    I'have reinstalled .NET 4.0, and i'll check for patches.

    I'll do this tonite.


    and reinstall PS V3
    • Modifié TonQ lundi 5 mars 2012 08:35
    lundi 5 mars 2012 08:35
  • I installed the beta, and it works :)

    Thanks for your implication ! both of you jrv, and boe. :)

    Good evening from Paris ;)

    lundi 5 mars 2012 17:40
  • I installed the beta, and it works :)

    Thanks for your implication ! both of you jrv, and boe. :)

    Good evening from Paris ;)

    Excellent.  I suspect soething was broken and the new install fixed it.  I also believe the beta install may update the Net bits for WMF 3.0 so if any are missing they would have gotten installeled.  The preview version may have been teh first version which had a lot of bugs and deficiencies.

    Always try to stay with the latest when it comes to tools.


    ¯\_(ツ)_/¯

    lundi 5 mars 2012 17:56
  • Indeed it was the first beta ... -_- :)
     At least i learned a few things :)

    just to know : i saw this in one of the example  you gave me

                $button1.remove_Click($button1_Click)
                $form1.remove_Load($FormEvent_Load)
                $form1.remove_Load($Form_StateCorrection_Load)
                $form1.remove_FormClosed($Form_Cleanup_FormClosed)

    is it necessary to "unload" everything once the form is closed ?

    • Modifié TonQ lundi 5 mars 2012 18:00
    lundi 5 mars 2012 17:58
  • Indeed it was the first beta ... -_- :)
     At least i learned a few things :)

    just to know : i saw this in one of the example  you gave me

                $button1.remove_Click($button1_Click)
                $form1.remove_Load($FormEvent_Load)
                $form1.remove_Load($Form_StateCorrection_Load)
                $form1.remove_FormClosed($Form_Cleanup_FormClosed)

    is it necessary to "unload" everything once the form is closed ?

    It was not the first beta. I think you mean it was the first CTP (Community Technology Preview).  That version was very flakey.  CRP2 was much better.

    No you do not need to remove anything.  The form will go away when the $form1 variable is removed which happens when the script finishes (returns) and the form is closed.  Garbage collection is automatic and does not usually need to be triggered.

    The code you see is a residue of having deleted the default events which was not necessary but I wanted tot reduce the code to as simple a bit as I could so it would be an understandable demo. I now have it available to post for others.


    ¯\_(ツ)_/¯

    lundi 5 mars 2012 18:15
  • Okay! that's what i supposed.

    do you have a blog or something ?

    lundi 5 mars 2012 18:16
  • Okay! that's what i supposed.

    do you have a blog or something ?

    Had a blog but decided that there were so many great blogs that mine would be redundant.  Everytime I searched a topic that I was going to write about I would find otheres who were doing such a good job that I didn't see a reason to do teh blog item.

    As for form with PowerSHell and PromalFormsCE this is a very good blog: http://www.scriptinganswers.com/blog/

    Alex is great with examples of how to use controls.


    ¯\_(ツ)_/¯

    lundi 5 mars 2012 18:29
  • Alright, thanks for the info,

    and again thanks you for your time :)

    lundi 5 mars 2012 18:37