473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Removing listbox flash in .NET

I created form which uses double buffering for everything.
If form is resized, listbox content is flashing.
In MONO ListBox is resized smoothly.

How to fix code so that it does not flash in .NET also ?

Andrus.

using System.Windows.Forms;

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

class ReportDialogForm : Form
{
public ReportDialogForm()
{
DoubleBuffered = true;
tabControl1 = new BufferedTabControl();
tabPage1 = new BufferedTabPage();
reportListBox = new BufferedListBox();
tabControl1.Dock = DockStyle.Fill;
tabControl1.Controls.Add(tabPage1);
tabPage1.Controls.Add(reportListBox);
reportListBox.Dock = DockStyle.Fill;
Controls.Add(tabControl1);
for (int i = 0; i < 100; i++)
reportListBox.Items.Add("MMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMM");
}

class BufferedListBox : ListBox
{
internal BufferedListBox()
{
DoubleBuffered = true;
}
}

class BufferedTabControl : TabControl
{
internal BufferedTabControl()
{
DoubleBuffered = true;
}
}

class BufferedTabPage : TabPage
{
internal BufferedTabPage()
{
DoubleBuffered = true;
}

}

BufferedTabControl tabControl1;
BufferedTabPage tabPage1;
BufferedListBox reportListBox;
}

Sep 11 '08 #1
4 2461
On 11/09/2008 in message <#W**************@TK2MSFTNGP05.phx.gblAndrus
wrote:
for (int i = 0; i < 100; i++)
reportListBox.Items.Add("MMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMM");
}
I was able to speed up a ListView which took 38 seconds to add 1003 files
by adding them to an array of ListViewItems then using AddRange after the
loop, it now takes about 0.8 seconds.

May be worth a try with a ListBox, may be too quick for any flicker to be
noticed.

--
Jeff Gaines Damerham Hampshire UK
There is absolutely no substitute for a genuine lack of preparation
Sep 11 '08 #2
maybe using ListBox.SuspendUpdate() before your loop and the
ListBox.BeginUpdate() after your loop will help

"Andrus" <ko********@hot.eewrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>I created form which uses double buffering for everything.
If form is resized, listbox content is flashing.
In MONO ListBox is resized smoothly.

How to fix code so that it does not flash in .NET also ?

Andrus.

using System.Windows.Forms;

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

class ReportDialogForm : Form
{
public ReportDialogForm()
{
DoubleBuffered = true;
tabControl1 = new BufferedTabControl();
tabPage1 = new BufferedTabPage();
reportListBox = new BufferedListBox();
tabControl1.Dock = DockStyle.Fill;
tabControl1.Controls.Add(tabPage1);
tabPage1.Controls.Add(reportListBox);
reportListBox.Dock = DockStyle.Fill;
Controls.Add(tabControl1);
for (int i = 0; i < 100; i++)

reportListBox.Items.Add("MMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMM");
}

class BufferedListBox : ListBox
{
internal BufferedListBox()
{
DoubleBuffered = true;
}
}

class BufferedTabControl : TabControl
{
internal BufferedTabControl()
{
DoubleBuffered = true;
}
}

class BufferedTabPage : TabPage
{
internal BufferedTabPage()
{
DoubleBuffered = true;
}

}

BufferedTabControl tabControl1;
BufferedTabPage tabPage1;
BufferedListBox reportListBox;
}

Sep 11 '08 #3
maybe using ListBox.SuspendUpdate() before your loop and the
ListBox.BeginUpdate() after your loop will help
Flashing occurs when listbox is resized.
Loop is running only in constructor.
So this does not have any effect.

Andrus.

Sep 12 '08 #4
I was able to speed up a ListView which took 38 seconds to add 1003 files
by adding them to an array of ListViewItems then using AddRange after the
loop, it now takes about 0.8 seconds.

May be worth a try with a ListBox, may be too quick for any flicker to be
noticed.
Add code is running in constructor only.
The flashing occurs when form is resized.
Constructor speed does not have any affect for this.

Actual issues seems to be that .NET does not pass Doublebuffered setting to
underlying control.
See
https://bugzilla.novell.com/show_bug.cgi?id=417962

for related info.

Andrus.

Sep 12 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: julio | last post by:
I noticed that pressing spacebar when a listbox has the focus scrolls the listbox to the first selected item. I'm intercepting the spacebar press event at form level for stopping and starting...
12
by: Magix | last post by:
Hi, Everytime I received a fix-length of string, let say 15 (the unused portion will filled with Spaces before receive), I want to remove the Spaces from END until I encounter a non-space char....
3
by: Jeremy Owens-Boggs | last post by:
We are trying to implement a dual list box selection where you have two list boxes, You highlight items in the right side list box, click a button and this moves those items over to the left hand...
3
by: Alpha | last post by:
I have 3 radio buttons for include, exclued or 'select all' from the listbox items. If a user selects the 'Select All' button' then all items in listbox is hi-lited as selected. Now, when user...
0
by: RA | last post by:
To remove an item from a listbox I tried; document.getElementById("lsTest").remove(new Option("Test3","Test3")); and document.getElementById("lsTest").remove("Test3"); neither of above work....
1
by: tony | last post by:
Hello! If you drag a ListBox into a windowform and then right click on this ListBox and then chose property. When you have the properties up click on the flash symbol for seeing all the events...
6
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
2
by: Mark Rae | last post by:
Hi, Looking for some advice again... Imagine two ListBox controls denoting something like students and team membership e.g. many students can be members of many teams (e.g. the hockey team,...
1
by: callbooks | last post by:
Hello Everyone, I am really a VB Newbie. I just want to ask how I can store a text and a value separately on a listbox. Example: listBox1.Item.Text = "USB Flash Drive" listBox1.Item.Value...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.