Public/Reset-WFDataGridViewFormat.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
function Reset-WFDataGridViewFormat { <# .SYNOPSIS The Reset-DataGridViewFormat function will reset the format of a datagridview control .DESCRIPTION The Reset-DataGridViewFormat function will reset the format of a datagridview control .PARAMETER DataGridView Specifies the DataGridView Control. .EXAMPLE PS C:\> Reset-DataGridViewFormat -DataGridView $DataGridViewObj .NOTES Author: Francois-Xavier Cat Twitter:@LazyWinAdm www.lazywinadmin.com github.com/lazywinadmin #> [CmdletBinding(SupportsShouldProcess = $true)] param ( [Parameter(Mandatory = $true)] [System.Windows.Forms.DataGridView]$DataGridView ) BEGIN { Add-Type -AssemblyName System.Windows.Forms } PROCESS { if ($PSCmdlet.ShouldProcess($DataGridView, "Reset the format")) { $DataSource = $DataGridView.DataSource $DataGridView.DataSource = $null $DataGridView.DataSource = $DataSource #$DataGridView.RowsDefaultCellStyle.BackColor = 'White' #$DataGridView.RowsDefaultCellStyle.ForeColor = 'Black' $DataGridView.RowsDefaultCellStyle = $null $DataGridView.AlternatingRowsDefaultCellStyle = $null } } } |