Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Removing flash during resize

Removing flash during resize

Scheduled Pinned Locked Moved C#
graphicsadobetutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndrusM
    wrote on last edited by
    #1

    If window is resized, listbox flashes. how to remove flash during resize ?

    using System;
    using System.Windows.Forms;
    using System.Collections.Generic;
    using System.Drawing;

    public class Test
    {
    static void Main()
    {
    Application.Run(new ReportDialogForm());
    }
    }

    class ReportDialogForm : Form
    {

    public ReportDialogForm()
    {
        tabControl1 = new TabControl();
        tabPage1 = new TabPage();
        reportListBox = new ListBox();
        tabControl1.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom)
                                | AnchorStyles.Left)
                                | AnchorStyles.Right)));
        tabControl1.Controls.Add(tabPage1);
        tabControl1.Location = new Point(0, 0);
        tabControl1.Padding = new Point(0, 0);
        tabControl1.SelectedIndex = 0;
        tabControl1.Size = new Size(591, 296);
        tabControl1.TabIndex = 0;
        tabPage1.Controls.Add(reportListBox);
        tabPage1.Location = new Point(4, 29);
        tabPage1.Margin = new Padding(0);
        tabPage1.Size = new Size(583, 263);
        tabPage1.TabIndex = 0;
        tabPage1.Layout += new LayoutEventHandler(tabPage1\_Layout);
        reportListBox.Anchor = AnchorStyles.None;
        reportListBox.Size = new Size(287, 384);
        reportListBox.TabIndex = 1000;
        ClientSize = new Size(588, 292);
        Controls.Add(tabControl1);
    
        for (int i = 0; i < 100; i++)
            reportListBox.Items.Add(  "MMMMMMMMMMMMMMMMMMMMMM");
    
        Load += new EventHandler(ReportDialogForm\_Load);
    }
    
    void ReportDialogForm\_Load(object sender, EventArgs e)
    {
        StartPosition = FormStartPosition.Manual;
        Location = new Point(10, 10);
        ClientSize = new Size(400, 400);
    }
    
    
    
    void tabPage1\_Layout(object sender, LayoutEventArgs e)
    {
        SuspendLayout();
        int height = 100;
        reportListBox.Top = height;
        reportListBox.Height = tabPage1.Height - height;
        reportListBox.Width = tabPage1.Width / 2;
        reportListBox.Left = 0;
        ResumeLayout();
    }
    
    TabControl tabControl1;
    TabPage tabPage1;
    ListBox reportListBox;
    

    }

    Andrus

    J 1 Reply Last reply
    0
    • A AndrusM

      If window is resized, listbox flashes. how to remove flash during resize ?

      using System;
      using System.Windows.Forms;
      using System.Collections.Generic;
      using System.Drawing;

      public class Test
      {
      static void Main()
      {
      Application.Run(new ReportDialogForm());
      }
      }

      class ReportDialogForm : Form
      {

      public ReportDialogForm()
      {
          tabControl1 = new TabControl();
          tabPage1 = new TabPage();
          reportListBox = new ListBox();
          tabControl1.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom)
                                  | AnchorStyles.Left)
                                  | AnchorStyles.Right)));
          tabControl1.Controls.Add(tabPage1);
          tabControl1.Location = new Point(0, 0);
          tabControl1.Padding = new Point(0, 0);
          tabControl1.SelectedIndex = 0;
          tabControl1.Size = new Size(591, 296);
          tabControl1.TabIndex = 0;
          tabPage1.Controls.Add(reportListBox);
          tabPage1.Location = new Point(4, 29);
          tabPage1.Margin = new Padding(0);
          tabPage1.Size = new Size(583, 263);
          tabPage1.TabIndex = 0;
          tabPage1.Layout += new LayoutEventHandler(tabPage1\_Layout);
          reportListBox.Anchor = AnchorStyles.None;
          reportListBox.Size = new Size(287, 384);
          reportListBox.TabIndex = 1000;
          ClientSize = new Size(588, 292);
          Controls.Add(tabControl1);
      
          for (int i = 0; i < 100; i++)
              reportListBox.Items.Add(  "MMMMMMMMMMMMMMMMMMMMMM");
      
          Load += new EventHandler(ReportDialogForm\_Load);
      }
      
      void ReportDialogForm\_Load(object sender, EventArgs e)
      {
          StartPosition = FormStartPosition.Manual;
          Location = new Point(10, 10);
          ClientSize = new Size(400, 400);
      }
      
      
      
      void tabPage1\_Layout(object sender, LayoutEventArgs e)
      {
          SuspendLayout();
          int height = 100;
          reportListBox.Top = height;
          reportListBox.Height = tabPage1.Height - height;
          reportListBox.Width = tabPage1.Width / 2;
          reportListBox.Left = 0;
          ResumeLayout();
      }
      
      TabControl tabControl1;
      TabPage tabPage1;
      ListBox reportListBox;
      

      }

      Andrus

      J Offline
      J Offline
      Jordanwb
      wrote on last edited by
      #2

      In the form's properties there's an option "DoubleBuffered" try setting it to true.

      A 1 Reply Last reply
      0
      • J Jordanwb

        In the form's properties there's an option "DoubleBuffered" try setting it to true.

        A Offline
        A Offline
        AndrusM
        wrote on last edited by
        #3

        Thank you. I added DoubleBuffered = true; as first line in constructor:

        public ReportDialogForm()
        {
            DoubleBuffered = true;
        

        ...

        However, listbox still blinks on resize. Adding DoubleBuffered did not make any difference.

        Andrus

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups