473,699 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

updating a ListBox's elements

Hi, I'm doing something where I add custom objects to a ListBox which have
aToString() method overriden so it displays what I want. When adding
instances of these custom objects to the ListBox I also put the same
references in a Hashtable so my program can obtain and modify these objects
without iterating through entire ListBox looking for what I want.

The problem is though, when I update these objects the changes are not being
reflected in the ListBox (The ToString method should be returning something
else but it isn't). There can only be two reasons for this:

1. The ListBox creates it's own copy of whatever object you put into it's
Items collection (This would be really stupid if it does!)

2. More likely, I just don't know how to update the ListBox so it repaints
itself... I tried claling the Refresh() method but tht's not doing it. What
method could I use?
Nov 17 '05 #1
1 2704
"MrNobody" <Mr******@discu ssions.microsof t.com> wrote in message
news:DE******** *************** ***********@mic rosoft.com...
Hi, I'm doing something where I add custom objects to a ListBox which have
aToString() method overriden so it displays what I want. When adding
instances of these custom objects to the ListBox I also put the same
references in a Hashtable so my program can obtain and modify these
objects
without iterating through entire ListBox looking for what I want.

The problem is though, when I update these objects the changes are not
being
reflected in the ListBox (The ToString method should be returning
something
else but it isn't). There can only be two reasons for this:

1. The ListBox creates it's own copy of whatever object you put into it's
Items collection (This would be really stupid if it does!)

2. More likely, I just don't know how to update the ListBox so it repaints
itself... I tried claling the Refresh() method but tht's not doing it.
What
method could I use?


You might try the listBox.Update method. That will cause the ListBox to be
repainted.

The other problem, and I don't think this is the case, could be that the
ListBox Items collection has its own ToString method that is overriding you
ToString method.

carl
Nov 17 '05 #2

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

Similar topics

2
4938
by: James Goodman | last post by:
I have a listbox named sub1 on an asp page. I need to fill this list with values from a table. These are selected based upon the selection of a value/s in another listbox. It was suggested that I use a hidden iframe on my main page, & carry out the processing inside the frame, using jscript. If I open the page in a browser, & make a selection in the first listbox (named main), the data in the frame appears to be processed correctly, the...
4
2310
by: f_salazar | last post by:
English Version !! Hi !! I have a page with a Form, inside the form I have listbox with 'X' elements. Wend I submit the page, an ASP process inside the page have to read those elements and then save them in a database. I try Request.Form("listbox") but doesnt work !
1
3038
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 delete a record. I delete the row from the datatable and update the database with the adapter and that all works good. The record is removed from the listbox. Here is my problem.
14
18731
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe is that as more and more are added, population of the list box takes longer and longer. ie the first 10th of the item set are added much much quicker than the last 10th. THis occurs with about 40,000 listbox items. My worry is the listbox may...
2
3614
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, the football team, the athletics team etc). Team membership is managed on a standard web page with two ListBox controls - the one on the left shows which team(s) the student is not a
6
3959
by: Zytan | last post by:
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
4
4632
by: bogdan | last post by:
Hi, I have two listboxes on a page and need to move items between them - using buttons (e.g. "<<" ">>"). Can this be done on a client side in asp.net? I'd like to avoid hitting the server on every add/remove. Thanks, Bogdan
3
2729
by: Reg Verrin | last post by:
I have a program that displays constantly changing prices which it sources from the web once per second. The prices are displayed on a Listbox (not the best choice but there are good reasons for this). The Listbox flickers when updating and I can't find a solution on the net. Here is the code: 'update Listbox
15
2363
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make things look better visually for that, I created a listbox under the text box. She enters the number in the text box, clicks another button I added and the number is stored in the list box. Then my plan was to grab all those numbers from the list box...
0
8686
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9033
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.