I would like to know how I can drag some data from a datagridview to a listbox. I see alot of examples about dragging files from the explorer to a listbox in a powershell script, but I cannot find an example about drag and drop between two powershell objects.
I have seen some VB examples, but I cannot translate them to powershell (I have never programmed in VB).
The code below is an example, of what I want.
Regard,
Marco
#region DefineForm #Define Form1 $form1 = New-Object System.Windows.Forms.Form $form1.Text = "form1" $form1.Name = "form1" $form1.DataBindings.DefaultDataSourceUpdateMode = 0 $form1.Location = New-Object System.Drawing.Point(1,1) $form1.WindowState = "Normal" $form1.StartPosition = "CenterScreen" $Form1.AutoSize = $True $Form1.AutoSizeMode = "GrowAndShrink" #endregion DefineForm #region Grid1 #Define table $DataGridView1 = New-Object System.Windows.Forms.DataGridView $DataGridView1.AllowUserToAddRows = $false $DataGridView1.AllowUserToDeleteRows = $false $DataGridView1.Top = 1 $DataGridView1.Left = 1 $DataGridView1.Height = 100 $DataGridView1.Width = 210 $DataGridView1.ColumnHeadersVisible = $true $DataGridView1.ColumnHeadersHeight = 20 #Add Columns $Column1 = New-Object System.Windows.Forms.DataGridViewTextboxColumn $Column1.Width = 150 $Column1.Name = 'ServerName' $DataGridView1.Columns.Add($Column1) $DataGridView1.Rows.Add('Server1') $DataGridView1.Rows.Add('Server2') $form1.Controls.AddRange(($DataGridView1)) #endregion Grid1 #region Listbox1 #objLabel_ClusterName $objLabel1 = New-Object System.Windows.Forms.Label $objLabel1.Location = New-Object System.Drawing.Point(1,150) $objLabel1.Size = New-Object System.Drawing.Size(100,20) $objLabel1.Text = "ServerName" $form1.Controls.Add($objLabel1) $objListBox1 = New-Object System.Windows.Forms.listBox $objListBox1.Location = New-Object System.Drawing.Point(130,150) $objListBox1.Size = New-Object System.Drawing.Size(130,20) $objListBox1.AllowDrop = $true $form1.Controls.Add($objListBox1) #endregion Listbox1 #region StartForm #Start form $form1.ShowDialog() #endregion StartForm