Create a DataGridView and export to a csv
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Create a DataGridView and export to a csv
Something like these, i search on google but i found only C++ applications, few examples with powershell
- Attachments
-
- 2.png (22.68 KiB) Viewed 2181 times
-
- 1.jpg (72.73 KiB) Viewed 2181 times
Re: Create a DataGridView and export to a csv
To sure search and sort functions use the DefaultDataView on the data table object.
$DataGridView.DefaultDataView.Find (or Filter).
Here is the only example I have:
$DataGridView.DefaultDataView.Find (or Filter).
Here is the only example I have:
- Attachments
-
- Demo-DGVSortFormat.ps1
- (7.76 KiB) Downloaded 117 times
Re: Create a DataGridView and export to a csv
Ok no problem now to add a column, but have you got a sample how to insert it ?jvierra wrote:You can add all user to a combo box when you define the column.
Re: Create a DataGridView and export to a csv
This is working, but my problem is working when i insert COMPUTERNAME in the filter, with DOMAIN ACCOUNT ( that has a space between the 2 words ), doesn't work
- $buttonFilter.add_Click({
- $datagridview.DataSource.DefaultView.RowFilter = "DOMAIN ACCOUNT LIKE '$($textboxFilter.Text)*'" })
Re: Create a DataGridView and export to a csv
solved with [], but i can't add the second and third filter
- $datagridview.DataSource.DefaultView.RowFilter = "COMPUTERNAME LIKE '$($textboxFilter.Text)*'"
- $datagridview.DataSource.DefaultView.RowFilter = "[LOCAL ACCOUNT] LIKE '$($textboxFilter.Text)*'"
- $datagridview.DataSource.DefaultView.RowFilter = "[DOMAIN ACCOUNT] LIKE '$($textboxFilter.Text)*'"
Re: Create a DataGridView and export to a csv
Found a solution
Public it below so it will be useful for those who will encounter my own problem
Public it below so it will be useful for those who will encounter my own problem
- $datagridview.DataSource.DefaultView.RowFilter = "COMPUTERNAME LIKE '$($textboxFilter.Text)*' OR [LOCAL ACCOUNT] LIKE '$($textboxFilter.Text)*' OR [DOMAIN ACCOUNT] LIKE '$($textboxFilter.Text)*'"
Re: Create a DataGridView and export to a csv
I try to insert combox, and ok, no problem, but when i export there are no values related at combox
maybe binding with datatable.. but i can't find the right code
maybe binding with datatable.. but i can't find the right code
- $dt = New-Object System.Data.DataTable
- $i = $dataGridView.Columns.Add('COMPUTERNAME', 'COMPUTERNAME')
- $c = $dataGridView.Columns[$i]
- $c.width = 150
- $c.DataPropertyName = 'COMPUTERNAME'
- [void]$dt.Columns.Add($c.DataPropertyName)
- $i = $dataGridView.Columns.Add('LOCAL ACCOUNT', 'LOCAL ACCOUNT')
- $c = $dataGridView.Columns[$i]
- $c.width = 150
- $c.DataPropertyName = 'LOCAL ACCOUNT'
- [void]$dt.Columns.Add($c.DataPropertyName)
- $Column3 = New-Object System.Windows.Forms.DataGridViewComboBoxColumn
- $Column3.HeaderText = "DOMAIN ACCOUNT"
- $Column3.Width = 150
- $Column3.HeaderCell.Style.Alignment = "middlecenter"
- $Column3.DefaultCellStyle.Alignment = "middlecenter"
- [void]$DataGridView.Columns.Add($Column3)
- $UserList= Get-ADUser -Filter * -SearchBase 'OU=USERS,DC=DOM,DC=LOCAL' | Select -ExpandProperty SamAccountName
- [void]$Column3.Items.AddRange($UserList)