I was trying to add a background image to the tab control
$tc_ASSTabControl.BackgroundImage = [System.Drawing.Image]::FromFile('C:\Users\me\test\image1.jpg')
Here is the code to define the tab control
# Creating Tab Control
$tc_ASSTabControl = New-Object System.Windows.Forms.TabControl
# Customizing the ASS Tab Control
$tc_ASSTabControl | ForEach-Object {
$_.DataBindings.DefaultDataSourceUpdateMode = 0
$_.Location = New-Object System.Drawing.Point(18, 65)
$_.Name = "tc_ASSTabControl"
$_.Width = 850
$_.Height = 580
$_.BackColor = [System.Drawing.Color]::Transparent
}
When the background image is added, the form flickers when the form is loaded initially and whenever the tab(SelectedIndex of tab control) is changed.
I tried the following option
Setting DoubleBuffered property to true
#This code doesn't work
$form.DoubleBuffered = $true
Here is a relevant thread on How to fix the flickering in User Controls.
The backcolor property of each control was set to "Transparent" by
BackColor = [System.Drawing.Color]::Transparent
Here is the screen capture of the issue. This happens when the form is loaded as well.
Here is an example of how I have defined the label at the top of the first tab, in case that helps to understand the reason for the flickering.
$lbl_BrowseSearchFolder = New-Object system.Windows.Forms.Label -Property @{
text = "Browse for the folder that is to be searched"
AutoSize = $true
width = 25
height = 10
location = New-Object System.Drawing.Point(29, (25 + $ySpacer))
Font = 'Arial,10'
BackColor = [System.Drawing.Color]::Transparent
}
As you may see from the image, it's the controls on "Search Criteria" tab that are loaded with a lag. Is there any property of those controls that can be set to prevent this lag in loading?
Could someone suggest a way to fix the flickering issue on PowerShell form