PrimalForm: How does the DataGrid work?
PrimalForm: How does the DataGrid work?
I'm familiar with the datagridview in VB.NET but the DataGrid doesn't seem to work the same.I'm not trying to bind it to a datasource, just use it as it for the table functionality.I worked on it for a couple hours and made no progress so I just converted it to a DataGridView.How should it have been done?
PrimalForm: How does the DataGrid work?
This PowerShell script was written before PrimalForms was available, but maybe it will give you an idea of how to use the DataGrid.
For other script development questions, I recommend using the PowerShell forum at ScriptingAnswers.com. Use the forums here to report bugs or problems.
Code: Select all
Function Get-ProcessSummary {
$procs=Get-Process | select name,description,starttime,path -errorAction Silentlycontinue
foreach ($process in $procs) {
if ($process.description -IsNot [string]) {
$procname=$process.name}
else {
$procname=$process.description
}
if ($process.starttime -IsNot [DateTime]) {
$procTime="N/A" }
else {
$procTime=($process.starttime).ToString()
}
if ($process.path -IsNot [string]) {
$procPath="N/A" }
else {
$procPath=$process.path
}
#create new object to hold values
$obj = New-Object PSObject
Add-Member -inputobject $obj -membertype NoteProperty -Name Name -value $procname
Add-Member -inputobject $obj -membertype NoteProperty -Name StartTime -value $procTime
Add-Member -inputobject $obj -membertype NoteProperty -Name Path -value $procPath
Write-Output $obj
}
}
[reflection.assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
[reflection.assembly]::LoadWithPartialName("System.Drawing") | Out-Null
$form = New-Object System.Windows.Forms.Form
$form.Size = New-Object System.Drawing.Size 800,400
$Form.Text = "Process Summary"
$DataGridView = New-Object System.windows.forms.DataGrid
$array= New-Object System.Collections.ArrayList
$griddata=@(ps | write-output)
$array.AddRange($griddata)
$DataGridView.DataSource = $array
$DataGridView.Dock = "Fill"
$DataGridView.AllowSorting=$True$form.Controls.Add($DataGridView)
$form.topmost = $True
$form.showdialog() | Out-Null
PrimalForm: How does the DataGrid work?
Thanks for the Snippet Jeff
How would datagrid compare to the gridview (out-gridview) cmdlet in CTP3?
Is it possible to embed that object into a form?
I've been able to sucessfully create some forms using the datagrid, I'd really like to provide similar sort and filter functionality as gridview and while I expect I could write that into my powershell form, I was curiuos about just using the out-gridview cmdlet.
Thanks.
How would datagrid compare to the gridview (out-gridview) cmdlet in CTP3?
Is it possible to embed that object into a form?
I've been able to sucessfully create some forms using the datagrid, I'd really like to provide similar sort and filter functionality as gridview and while I expect I could write that into my powershell form, I was curiuos about just using the out-gridview cmdlet.
Thanks.
PrimalForm: How does the DataGrid work?
As far as I know the underlying .NET class is the same but clearly with additional features in Out-Gridview. The ability to filter is clearly an advantage. I'm not sure how or even if you could embed it in a WinForm. I tend to think it is unlikely.