how to avoid screen flicker?

by 정나래   Last Updated June 30, 2020 03:26 AM - source

WPF controls are on Winform.
When Winform is loaded, flickering occurs.

To avoid flickering, I added the below codes.

For Wpf Control

public Constructor()
    this.Loaded += Control_Loaded;

private void Control_Loaded(object sender, RoutedEventArgs e)
    HwndSource hwnd = System.Windows.PresentationSource.FromVisual(this) as HwndSource;
    HwndTarget target = hwnd.CompositionTarget;
    target.RenderMode = RenderMode.SoftwareOnly;

For Winform

protected override CreateParams CreateParams
      CreateParams handleparam = base.CreateParams;
      handleparam.ExStyle |= 0x02000000;
      return handleparam;

Flicker seems to have been resolved.

However, other problem arises.
There is DataGridView in Form.
In the DataGridView, the next row of the last row is displayed as an afterimage.
for example, if row count is 15, when scrolling last row, the row is displayed below the 15th row. The row is not exist row but the row is shown as an afterimage.
If codes about CreateParams are removed, DataGridView works fine but flickering occurs on Load.

How can I solve this problem?

Tags : c# .net wpf flicker

Related Questions

Background image flickering of wxWidgets Panel

Updated May 09, 2017 10:26 AM

Laps Animation(flicker) in html

Updated July 15, 2017 01:26 AM

Unable to avoid form flickering completely

Updated March 20, 2019 11:26 AM

hover display flicker jquery

Updated May 15, 2017 13:26 PM