Search found 11854 matches

by jvierra
Sat Feb 24, 2018 12:02 pm
Forum: PowerShell GUIs
Topic: Using datagrid with arraylist
Replies: 7
Views: 89

Re: Using datagrid with arraylist

$datagridview1.DataSource | Export-Csv d:\scripts\testds.csv
by jvierra
Sat Feb 24, 2018 11:57 am
Forum: PowerShell GUIs
Topic: Using datagrid with arraylist
Replies: 7
Views: 89

Re: Using datagrid with arraylist

Either export to a CSV or write a custom file export.

The DataSource can be looped through and saved to a file.
by jvierra
Sat Feb 24, 2018 11:01 am
Forum: PowerShell GUIs
Topic: Using datagrid with arraylist
Replies: 7
Views: 89

Re: Using datagrid with arraylist

If you want to pull from a file then you will need to force the read:

$datagridview1.DataSource = [collections.arraylist]( Get-Content d:\scripts\stringdata.txt -raw | ConvertFrom-StringData)
by jvierra
Sat Feb 24, 2018 10:56 am
Forum: PowerShell GUIs
Topic: Using datagrid with arraylist
Replies: 7
Views: 89

Re: Using datagrid with arraylist

Actually I take that back. You don't need to convert the hash. This works as expected. $stringdata = @' Name1=Value1 Name2=Value2 Name3=Value3 Name4=Value4 Name5=Value5 Name6=Value6 Name7=Value7 '@ $form1_Load={ $hash = $stringdata | ConvertFrom-StringData $datagridview1.DataSource = [System.Collect...
by jvierra
Sat Feb 24, 2018 10:13 am
Forum: PowerShell GUIs
Topic: Using datagrid with arraylist
Replies: 7
Views: 89

Re: Using datagrid with arraylist

Run this at a prompt and inspect the results. Get-Content -Path $PSScriptRoot\Preferences.txt | ConvertFrom-StringData You cannot convert a hash table to an arraylist You can only successfully convert objects to an arraylist. Think of the topology of the data. A hash would be one line in a grid. Rec...
by jvierra
Fri Feb 23, 2018 1:20 pm
Forum: Windows PowerShell
Topic: Powershell and Excel
Replies: 3
Views: 102

Re: Powershell and Excel

$xl = New-Object -Com Excel.Application $doc = $xl.Workbooks.Open(<path to workbook>) $xl.ActiveSheet.Cells.Item(2,3) = 'My value' $doc.Save() $doc.Close() $xl.Quit() See: https://stackoverflow.com/questions/39418045/how-do-you-add-data-into-an-excel-spreadsheet-from-powershell Search for examples ...
by jvierra
Thu Feb 22, 2018 9:08 am
Forum: Windows PowerShell
Topic: Datagridview - Go to row with letter on keydown
Replies: 2
Views: 79

Re: Datagridview - Go to row with letter on keydown

Gather the searchable items into an autocomplete textbox and let the user select from the dynamically filtered list. You can also use a DataTable source and use the row filter to force display of all matching values on each keystroke. The grid will display only all matching rows to the filter expres...
by jvierra
Thu Feb 22, 2018 9:03 am
Forum: Windows PowerShell
Topic: Receive-Job output is empty sometimes
Replies: 2
Views: 121

Re: Receive-Job output is empty sometimes

Nice job. Here is a more reliable way of coding this: Function Start-DriveEncryption { Param ( [Parameter(Mandatory = $true)] [Hashtable]$args ) $StatusBar.Text = "Enabling encryption" Write-Log -message "Enabling encryption" -component $script:component Add-JobTracker -Name 'DriveEncryption' -JobSc...
by jvierra
Tue Feb 20, 2018 2:30 pm
Forum: PowerShell GUIs
Topic: Resizable form: textboxes?
Replies: 1
Views: 82

Re: Resizable form: textboxes?

You will need to anchor to one or two location. Expanding a grid in four directions will be unmanageable. In some cases you have to catch the sizing event and manually calculate the limits.
by jvierra
Tue Feb 20, 2018 9:43 am
Forum: PowerShell GUIs
Topic: Problem with form refresh
Replies: 3
Views: 111

Re: Problem with form refresh

You cannot access a form from a job and you shouldn't try. Doing so can deadlock the form.
You cannot wait on a job in an event as it will freeze the form. Use the JobTracker control and your issues will be gone.