user1632018
user1632018

Reputation: 2555

Is their a way to stop the picturebox from flickering when being resized?

I have an image that I wanted to include in my vb.net app, so I sliced it up in photoshop and divided it into multiple picture boxes, and anchored them accordingly so when my application is resized it wont stretch all parts of the image. That is all good, it looks great and almost works great..except the fact that when the form is being resized it is causing the pictureboxes to flicker.

I know that the picturebox is not the fastest control, so I am geussing it is not refreshing fast enough. Aside from flickering it appears with a white background underneath even though the pictureboxes are transparent.

I tried adding a BG colour for the background hoping it would hide the flickering better while loading to no avail.

So my fist question would be is their any way of preventing this? If not is their a control that is faster that I could use?

Maybe a custom picture box someone knows, or even if you know a control thats faster. Basically any control that would allow a background image and transparent BG color would work as long as it is faster.

I really appreciate any help. Thanks. PS: My application is in VB.net but I am adding a C# tag aswell because I am most likely going to have to switch controls instead of repairing it through code.

Upvotes: 3

Views: 2611

Answers (2)

xpda
xpda

Reputation: 15813

Two ways to handle this are:

a) Resize the image in the picturebox so it is smaller and will redraw faster, or

b) Use a timer to redraw the image so it doesn't begin to redraw until 100 to 350 ms after the last resize event.

Upvotes: 1

Ankur Singh
Ankur Singh

Reputation: 81

Two avoid flickering in controls in form u can use following function Only copy it and paste it anywhere in form.vb

Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or &H2000000
            Return cp
        End Get
    End Property 'CreateParams

only paste anwhere it is readonly property

Upvotes: 7

Related Questions