Moved the code to Load and it runs correctly by just copying the code for one two a second and renaming the view.
In Load:
Code: Select all
$System_Windows_Forms_DataGridViewCellStyle_2 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
$System_Windows_Forms_DataGridViewCellStyle_2.Alignment = 'MiddleLeft'
$System_Windows_Forms_DataGridViewCellStyle_2.BackColor = 'Window'
$System_Windows_Forms_DataGridViewCellStyle_2.Font = 'Microsoft Sans Serif, 8.25pt'
$System_Windows_Forms_DataGridViewCellStyle_2.ForeColor = 'ControlText'
$System_Windows_Forms_DataGridViewCellStyle_2.SelectionBackColor = 'Red'
$System_Windows_Forms_DataGridViewCellStyle_2.SelectionForeColor = 'HighlightText'
$System_Windows_Forms_DataGridViewCellStyle_2.WrapMode = 'False'
$dgvOwner.DefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_2
$System_Windows_Forms_DataGridViewCellStyle_1 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
$System_Windows_Forms_DataGridViewCellStyle_1.Alignment = 'MiddleLeft'
$System_Windows_Forms_DataGridViewCellStyle_1.BackColor = 'Window'
$System_Windows_Forms_DataGridViewCellStyle_1.Font = 'Microsoft Sans Serif, 8.25pt'
$System_Windows_Forms_DataGridViewCellStyle_1.ForeColor = 'ControlText'
$System_Windows_Forms_DataGridViewCellStyle_1.SelectionBackColor = 'ForestGreen'
$System_Windows_Forms_DataGridViewCellStyle_1.SelectionForeColor = 'HighlightText'
$System_Windows_Forms_DataGridViewCellStyle_1.WrapMode = 'False'
$dgvEquipment.DefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_1