Visual Studio windows app - disable the screen updating

Hi all
I would like to know what i can do to disable the screan updating when i open a form in my project.

If a run below code, I see the screen updating all the time:

 carrier_name.MdiParent = Me
            carrier_name.Show()
            carrier_name.Focus()

Open in new window


Thanks again for your help
LVL 11
Wilder1626Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
what do you mean by Update?
0
Wilder1626Author Commented:
The screen is flickering when i open the multiple project forms.

Is there a way to stop the flickering?

In VB macro for excel, i was using ApplicationScreenUpdating = False.

Do we have a look a like for Visual studio?
0
Éric MoreauSenior .Net ConsultantCommented:
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Wilder1626Author Commented:
I have just tried, but still having the flickering.
0
Éric MoreauSenior .Net ConsultantCommented:
it would take a sample to repro on my side. do you have one?
0
Éric MoreauSenior .Net ConsultantCommented:
0
Wilder1626Author Commented:
Let me try again both solutions you gave me. Cause when i replicate the same thing in another project, everything looks good.

Pretty strange. Wonder if the Transparence on labels can cause the problem.
0
Wilder1626Author Commented:
I was able to replicate cause i still have the same problem.

On form1, on your left, go under Carrier / New setting. The form that will show will do some flickering.
WindowsApplication1.zip
0
Éric MoreauSenior .Net ConsultantCommented:
have you tried the other link code?
0
Wilder1626Author Commented:
not yet. but i'm testing it now.
0
Éric MoreauSenior .Net ConsultantCommented:
I'll wait until I get more news from you then
0
Wilder1626Author Commented:
I cant seems to figure this one out. How it really work and where to place the code.

sorry, i'm a newby
0
Éric MoreauSenior .Net ConsultantCommented:
do you have a very slow PC? I just tried and it is not that bad.

can you also try to put these lines in your Form2:
    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        SetStyle(ControlStyles.DoubleBuffer, True)
    End Sub

Open in new window

0
Éric MoreauSenior .Net ConsultantCommented:
add this code to your form2:


    'PREVENT FLICKERING 
    Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or 33554432
            Return cp
        End Get
    End Property
    Private Sub PreVentFlicker()
        With Me
            .SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
            .SetStyle(ControlStyles.UserPaint, True)
            .SetStyle(ControlStyles.AllPaintingInWmPaint, True)
            .UpdateStyles()
        End With

    End Sub

Open in new window


and change the constructor of your Form2 for:
    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        'SetStyle(ControlStyles.DoubleBuffer, True)
        PreVentFlicker()
    End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wilder1626Author Commented:
wow, looks like it's did stop flickering.

let me do one last test
0
Wilder1626Author Commented:
Thank you so much for your help

this is perfect
0
Wilder1626Author Commented:
HI Éric

I was wondering if it was normal that once the form2 opened, now other functionalities are not working anymore?

Ex: clear button or the send to grid button.

was i to put the below code in the Form2.load?

  ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        'SetStyle(ControlStyles.DoubleBuffer, True)
        PreVentFlicker()

Open in new window

0
Éric MoreauSenior .Net ConsultantCommented:
try removing the call to preventflicker and you will quickly discover if it is related or not
0
Wilder1626Author Commented:
Hi

i actualy  did the test, and once removed, it does work.
0
Éric MoreauSenior .Net ConsultantCommented:
reactivate the PreventFlicker and comment out this line:
.SetStyle(ControlStyles.AllPaintingInWmPaint, True)

Open in new window

0
Wilder1626Author Commented:
Thanks, i will test this and let you know shortly
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.