473,804 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hastable/SortedList->Combobox

Hello all,

I've looked on the net and can't seem to find what I need so I must be
searching badly or have (another) 'non-problem'.
I am simply trying to move the values of a hastable or sorted list into a
combobox control. I'm willing to lose the key item of the collection I just
need the values.
Surely i don't need to enumerate the entire collection adn add the values
one by one into the combobox?

Thanks
Nev
Nov 16 '05 #1
3 3739
"nevin" <nevin@[diespam]myself.com> wrote in message
news:40******** *************** @mercury.nildra m.net...
Hello all,

I've looked on the net and can't seem to find what I need so I must be
searching badly or have (another) 'non-problem'.
I am simply trying to move the values of a hastable or sorted list into a
combobox control. I'm willing to lose the key item of the collection I just need the values.
Surely i don't need to enumerate the entire collection adn add the values
one by one into the combobox?

Thanks
Nev


http://samples.gotdotnet.com/quickst...ding.cs&font=3

(URL will be word-wrapped)

Erik
Nov 16 '05 #2
Since ComboBox.Items is of the class ComboBox.Object Collection you can
use its AddRange(object[]) method to quickly add all the items. You
might have to use ICollection.Cop yTo() to get them from the hashtable in
to an Object[], although I seem to remember an easier way, I just can't
find it at the moment.

I hope that helps!
DC
Nov 16 '05 #3
The way I ended up doing it was:

combo.DataSourc e=sortedlist.Ge tValueList();

Thanks to Eric and DC for the pointers.

"nevin" <nevin@[diespam]myself.com> wrote in message
news:40******** *************** @mercury.nildra m.net...
Hello all,

I've looked on the net and can't seem to find what I need so I must be
searching badly or have (another) 'non-problem'.
I am simply trying to move the values of a hastable or sorted list into a
combobox control. I'm willing to lose the key item of the collection I just need the values.
Surely i don't need to enumerate the entire collection adn add the values
one by one into the combobox?

Thanks
Nev

Nov 16 '05 #4

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

Similar topics

2
253
by: Brett Hewitson | last post by:
I am new to C# and I am trying to implement a class that implements the System.Collections.IDictionary class. So far this is what I have. using System; namespace Test1 { public class Preferences: System.Collections.IDictionary {
2
6964
by: Jim Heavey | last post by:
I thought I could create a "ListViewItem" and then bind that item to a combox box, but perhaps that is was with an ASP.Net control. When I create a listViewItem and bind it to a combo box, it does bind, but what show up is something like ListViewItem{MyField}. So if I have a hastable, what mechanism would I use to create a bindable object such that I can define the "ValueMember" and "DisplayMember"? Thanks in advance for your...
18
1772
by: Doug Bell | last post by:
Hi, I have a function that loads Rows from a field in a DataTable into an ArrayList. See below: It also adds a Row (eg "All Areas"). I wanted this new row to be the first record so I added a preceeding space (eg " All Areas") and sorted the ArrayList. I have just found that there are some valid records that have one or more
7
1492
by: Brett Romero | last post by:
I'd like to copy a object1 into object2 so object2 can be manipulated. Object1 is coming form the middle layer into the UI layer. I'd like to rename a field in Object2 from "somethingID" to just "ID" and do this several times for a few middle layer objects. This will allow me to create generic<> lists and reference the field ID against many object2s that are similar to object1. The middle layer objects have ID fields with different...
4
10128
by: SHEBERT | last post by:
Here is an example of a SortedList that works as a datasource to the ComboBox and a generic SortedList<that does not works as a datasource to the ComboBox. Why? If I use List and generic List<>, both works. private void Form1_Load(object sender, EventArgs e) { System.Collections.SortedList QA1 = new System.Collections.SortedList();
2
1706
by: Chicken15 | last post by:
Hi Group. First of all I'm sorry for asking (maybe) such easy questions. But I'm quite stuck now and couldn't come up with a solution by using my C# book or googling. So it would be nice if someone could help me out. Now first of all I want to describe the setting in a simpler (I'm using Visual Studio 2005): Form: One comboBox (dropdown list) and 2 buttons. Classes: Class1 with a function do() which plainly returns a string.
19
2212
by: active | last post by:
I'm using a ComboBox to display objects of a class I've defined, say CQQ. Works great except somehow I occasionally set an Item to a String object instead of an object of type CQQ. It looks like Text replaces an item or something like that. This results in a runtime error at which time I learn that the item that should be CQQ is a String.
9
2014
by: active | last post by:
Can you see why this does not sort the list? It displays OK but is not sorted Thanks for any help
0
9595
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
10603
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...
1
10356
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
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
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
5536
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...
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.