I am stumped, so I am hoping someone could give me some help here. I am trying to create a Windows Form using PrimalForms Community Edition 2011, that utilizes a DataGridView. I was able to get one created using the following (shamelessly stolen from http://sev17.com/2009/08/02/building-powershell-guis-with-primal-forms/):
endregion Generated Form Objects
$bindingSource1 = new-object System.Windows.Forms.BindingSource
$dataAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$serverName = “myserver.com”
$databaseName = “myDB”
$query = ‘select * from tblPotConflicts’
#———————————————-
#Generated Event Script Blocks
#———————————————-
#Provide Custom Code for events specified in PrimalForms.
$Form1_Load=
{
$dataGridView1.DataSource = $bindingSource1
$connString = “Server=$serverName;Database=$databaseName;Integrated Security=SSPI;”
$dataAdapter.SelectCommand = new-object System.Data.SqlClient.SqlCommand ($query,$connString)
$commandBuilder = new-object System.Data.SqlClient.SqlCommandBuilder $dataAdapter
$dt = New-Object System.Data.DataTable
[void]$dataAdapter.fill($dt)
$bindingSource1.DataSource = $dt
$dataGridView1.AutoResizeColumns([System.Windows.Forms.DataGridViewAutoSizeColumnsMode]::AllCellsExceptHeader)
}
This works excellently with creating the binding for the DataGridView, as you can't actually do that [as far as I can tell at least] within PrimalForms itself. What I am curious about is:
Can you Omit any columns from the DataGridView? I have a few columns that I would rather hide from the end-users if at all possible, and just manipulate them programmatically behind the scenes. I am no great shakes at SQL, so it is very possible this is something super basic and easy.
I have one column that I would like to make act as a ComboBox. I see that in C# they have a choice of column type DataGridViewComboBoxColumn, but I don't know how I can set that up in PowerShell. Does anyone hopefully have any suggestions/solutions on that?
Thank you in advance for any help/insight/suggestions you may be able to offer here.