473,382 Members | 1,247 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,382 software developers and data experts.

Updating listbox without refreshing window for each element added

In win32 there was a way to 'turn off' a listbox from updating until
you were done adding elements. Is there a way to do this in .NET?

Zytan

May 7 '07 #1
6 3936
On May 7, 4:38 pm, Zytan <zytanlith...@gmail.comwrote:
In win32 there was a way to 'turn off' a listbox from updating until
you were done adding elements. Is there a way to do this in .NET?

Zytan
Have you looked into the .SuspendLayout() and .ResumeLayout() methods?

May 7 '07 #2
Have you looked into the .SuspendLayout() and .ResumeLayout() methods?
I was thinking .BeginUpdate() and .EndUpdate()

May 8 '07 #3
Have you looked into the .SuspendLayout() and .ResumeLayout() methods?

No. The docs say:

"The SuspendLayout and ResumeLayout methods are used in tandem to
suppress multiple Layout events while you adjust multiple attributes
of the control. For example, you would typically call the
SuspendLayout method, then set the Size, Location, Anchor, or Dock
properties of the control, and then call the ResumeLayout method to
enable the changes to take effect."

So, it looks like this is close, but not quite what I want. Thanks.

Zytan

May 8 '07 #4
I was thinking .BeginUpdate() and .EndUpdate()

Yup, this is it!

"Maintains performance while items are added to the ListBox one at a
time by preventing the control from drawing until the EndUpdate method
is called."

But note:

"The preferred way to add multiple items to the ListBox is to use the
AddRange method of the ListBox.ObjectCollection class (through the
Items property of the ListBox). This enables you to add an array of
items to the list in a single operation. However, if you want to add
items one at a time using the Add method of the
ListBox.ObjectCollection class, you can use the BeginUpdate method to
prevent the control from repainting the ListBox each time an item is
added to the list. Once you have completed the task of adding items to
the list, call the EndUpdate method to enable the ListBox to repaint.
This way of adding items can prevent flickered drawing of the ListBox
when a large number of items are being added to the list."

Thanks!

Zytan

May 8 '07 #5
On May 7, 5:14 pm, not_a_commie <notacom...@gmail.comwrote:
Have you looked into the .SuspendLayout() and .ResumeLayout() methods?

I was thinking .BeginUpdate() and .EndUpdate()
Oh, yes. Silly me. :-)

May 8 '07 #6
I was thinking .BeginUpdate() and .EndUpdate()

I don't suppose there's such a thing for a RichTextBox?

Zytan

May 8 '07 #7

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

Similar topics

3
by: gdbjohnson-AT-yahoo-dot-ca-nospamplz | last post by:
I have a ListBox built of a simple custom object for the ListItems used to be able to hold a Data Value, and a Display Value, with accessors for each. I have overridden the ToString method to...
2
by: jdi | last post by:
Hello, I have a seemingly basic question about ASP.NET. I would like to create a page containing an image, which keeps swapping the url of the image source, without refreshing the entire page. ...
0
by: Dave | last post by:
Hi all, I have a listbox that is complex bound by an arraylist. The problem is that when I delete an object from the arraylist, the listbox does not reflect those changes. I tried refreshing...
1
by: Spock | last post by:
Hi. I have a form with a listbox and a few label fields all bound to a dataset. When i navigate the listbox the labels change accordingly. so far everything works good. I made a button to...
1
by: erin.sebastian | last post by:
Hello Everyone, I have created a small application in vb.net to maintain items in a database the problem i am having is that once i delete/add/edit an individual item the changes don't reflect in...
4
by: P K | last post by:
Hi, I have two listboxes on my form. One has a list of available values while the other is a list of selected values. So I select a value from list 1 and add it to list 2 when "add" button is...
5
by: JJ | last post by:
I want to have two lists (may have to be listboxes) on a page that are populated from a database. I then need to be able to click on an entry in one box and add it to the other, _preferably_...
13
by: honey99 | last post by:
Hi! I have to fix a problem in JSP.Actually,i have a JSP page say Ex1.jsp.In this Ex1.jsp i have an anchor tag which links into another JSP page i.e when i click on the link another pop-up window...
3
by: Sweetiecakes | last post by:
Hi I have an string array containing file paths. I have added them to a ListBox with AddRange(); When I delete an item from the ListBox, how can I delete the same item from the original...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.