Hi all,
Is it possible to populate a listbox from a hashtable (complexbind) where
the ValueMember of the listbox maps to the "key" member of the hashtable AND
the DisplayMember of the listbox maps to the "value" member of the
hashtable?
I found that it is impossible to use a hashtable as a listbox datasource
directly (from trial and error) and tried DirectCast-ing to an arraylist
without any success. Before I spend anymore time in vain complex binding, I
thought I'd ask to see if anyone has figured a method of doing so.
D 5 7837
Hi Dave!
didn't test it but it seems ok http://groups.google.com/groups?thre...40tkmsftngxa04
--
Best Regards
Yanick
"Dave" <dave(delete_th is)@miraclecatD ELETETHISTOO.co m> a écrit dans le
message de news:OR******** ******@TK2MSFTN GP15.phx.gbl... Hi all, Is it possible to populate a listbox from a hashtable (complexbind) where the ValueMember of the listbox maps to the "key" member of the hashtable
AND the DisplayMember of the listbox maps to the "value" member of the hashtable? I found that it is impossible to use a hashtable as a listbox datasource directly (from trial and error) and tried DirectCast-ing to an arraylist without any success. Before I spend anymore time in vain complex binding,
I thought I'd ask to see if anyone has figured a method of doing so.
D
Bummer, this only works in ASP.NET.
"Zoury" <yanick_lefebvr e at hotmail dot com> wrote in message
news:Om******** ******@TK2MSFTN GP14.phx.gbl... Hi Dave!
didn't test it but it seems ok http://groups.google.com/groups?thre...40tkmsftngxa04 -- Best Regards Yanick "Dave" <dave(delete_th is)@miraclecatD ELETETHISTOO.co m> a écrit dans le message de news:OR******** ******@TK2MSFTN GP15.phx.gbl... Hi all, Is it possible to populate a listbox from a hashtable (complexbind)
where the ValueMember of the listbox maps to the "key" member of the hashtable AND the DisplayMember of the listbox maps to the "value" member of the hashtable? I found that it is impossible to use a hashtable as a listbox datasource directly (from trial and error) and tried DirectCast-ing to an arraylist without any success. Before I spend anymore time in vain complex
binding, I thought I'd ask to see if anyone has figured a method of doing so.
D
oh sorry! i didn't pay much attention to the properties name from the
sample.
have you try this :
'***
Dim ht As Hashtable = New Hashtable(3)
ht.Add("item 1", 1)
ht.Add("item 2", 2)
ht.Add("item 3", 3)
ListBox1.Displa yMember = "key"
ListBox1.ValueM ember = "value"
Dim entry As DictionaryEntry
For Each entry In ht
ListBox1.Items. Add(entry)
Next
'***
note that for some reason you must affect DisplayMember and ValueMember
properties before adding the items or the displayed item might not be
correct... (plus i'm not quite sure why it's not the other way around)
--
Best Regards
Yanick
"Dave" <dave(delete_th is)@miraclecatD ELETETHISTOO.co m> a écrit dans le
message de news:eO******** ******@tk2msftn gp13.phx.gbl... Bummer, this only works in ASP.NET. "Zoury" <yanick_lefebvr e at hotmail dot com> wrote in message news:Om******** ******@TK2MSFTN GP14.phx.gbl... Hi Dave!
didn't test it but it seems ok http://groups.google.com/groups?thre...40tkmsftngxa04 -- Best Regards Yanick "Dave" <dave(delete_th is)@miraclecatD ELETETHISTOO.co m> a écrit dans le message de news:OR******** ******@TK2MSFTN GP15.phx.gbl... Hi all, Is it possible to populate a listbox from a hashtable (complexbind) where the ValueMember of the listbox maps to the "key" member of the
hashtable AND the DisplayMember of the listbox maps to the "value" member of the hashtable? I found that it is impossible to use a hashtable as a listbox
datasource directly (from trial and error) and tried DirectCast-ing to an
arraylist without any success. Before I spend anymore time in vain complex
binding, I thought I'd ask to see if anyone has figured a method of doing so.
D
Thanks Zoury!
I learned something new: looping with the "DictionaryEntr y" - This is
awesome and works faster than the datatable binding!
Forgive me for getting so excited over this, I am quite new to VB.Net!
"Zoury" <yanick_lefebvr e at hotmail dot com> wrote in message
news:ej******** ******@TK2MSFTN GP15.phx.gbl... oh sorry! i didn't pay much attention to the properties name from the sample.
have you try this : '*** Dim ht As Hashtable = New Hashtable(3) ht.Add("item 1", 1) ht.Add("item 2", 2) ht.Add("item 3", 3)
ListBox1.Displa yMember = "key" ListBox1.ValueM ember = "value"
Dim entry As DictionaryEntry For Each entry In ht ListBox1.Items. Add(entry) Next '***
note that for some reason you must affect DisplayMember and ValueMember properties before adding the items or the displayed item might not be correct... (plus i'm not quite sure why it's not the other way around)
-- Best Regards Yanick "Dave" <dave(delete_th is)@miraclecatD ELETETHISTOO.co m> a écrit dans le message de news:eO******** ******@tk2msftn gp13.phx.gbl... Bummer, this only works in ASP.NET. "Zoury" <yanick_lefebvr e at hotmail dot com> wrote in message news:Om******** ******@TK2MSFTN GP14.phx.gbl... Hi Dave!
didn't test it but it seems ok http://groups.google.com/groups?thre...40tkmsftngxa04 -- Best Regards Yanick "Dave" <dave(delete_th is)@miraclecatD ELETETHISTOO.co m> a écrit dans le message de news:OR******** ******@TK2MSFTN GP15.phx.gbl... > Hi all, > Is it possible to populate a listbox from a hashtable (complexbind)
where > the ValueMember of the listbox maps to the "key" member of the hashtable AND > the DisplayMember of the listbox maps to the "value" member of the > hashtable? > I found that it is impossible to use a hashtable as a listbox datasource > directly (from trial and error) and tried DirectCast-ing to an arraylist > without any success. Before I spend anymore time in vain complex binding, I > thought I'd ask to see if anyone has figured a method of doing so. > > D > >
Thanks Zoury!
I learned something new: looping with the "DictionaryEntr y" - This is
awesome and works faster than the datatable binding!
Forgive me for getting so excited over this, I am quite new to VB.Net!
"Zoury" <yanick_lefebvr e at hotmail dot com> wrote in message
news:ej******** ******@TK2MSFTN GP15.phx.gbl... oh sorry! i didn't pay much attention to the properties name from the sample.
have you try this : '*** Dim ht As Hashtable = New Hashtable(3) ht.Add("item 1", 1) ht.Add("item 2", 2) ht.Add("item 3", 3)
ListBox1.Displa yMember = "key" ListBox1.ValueM ember = "value"
Dim entry As DictionaryEntry For Each entry In ht ListBox1.Items. Add(entry) Next '***
note that for some reason you must affect DisplayMember and ValueMember properties before adding the items or the displayed item might not be correct... (plus i'm not quite sure why it's not the other way around)
-- Best Regards Yanick "Dave" <dave(delete_th is)@miraclecatD ELETETHISTOO.co m> a écrit dans le message de news:eO******** ******@tk2msftn gp13.phx.gbl... Bummer, this only works in ASP.NET. "Zoury" <yanick_lefebvr e at hotmail dot com> wrote in message news:Om******** ******@TK2MSFTN GP14.phx.gbl... Hi Dave!
didn't test it but it seems ok http://groups.google.com/groups?thre...40tkmsftngxa04 -- Best Regards Yanick "Dave" <dave(delete_th is)@miraclecatD ELETETHISTOO.co m> a écrit dans le message de news:OR******** ******@TK2MSFTN GP15.phx.gbl... > Hi all, > Is it possible to populate a listbox from a hashtable (complexbind)
where > the ValueMember of the listbox maps to the "key" member of the hashtable AND > the DisplayMember of the listbox maps to the "value" member of the > hashtable? > I found that it is impossible to use a hashtable as a listbox datasource > directly (from trial and error) and tried DirectCast-ing to an arraylist > without any success. Before I spend anymore time in vain complex binding, I > thought I'd ask to see if anyone has figured a method of doing so. > > D > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
by: Wishing I was skiing mom |
last post by:
Newbie to VB .NET.
My solution contains an item maintenance screen, one of the fields on the
screen is an item status, this field is defined as a listbox. The listbox
item property contains a collection of status values. If I later pull an
item record from the dataset into this item maintenance screen I cannot seem
to get the status value that is contained in the dataset to display on the
form, it displays the first value in the listbox...
|
by: JH |
last post by:
I have a Hashtable of strings to strings (i.e. names => values). This
hashtable
is populated dynamicly so it's contents are only known at runtime. I wish to
populate a PropertyGrid control with the contents of this Hashtable. Is this
possible? If so, how?
Thanks in advance,
John
|
by: Yul |
last post by:
Hi,
We are in the process of designing an ASP.NET app, where a user will
enter some 'Customer ID' to be queried in the database. If the ID is
valid, several stored procedures will be called to populate multiple
webpages containing customer information. There isn't a one-to-one
correlation between the stored procedure and a webpage. In other
words, a webpage may have to refer to 1 or more DataTables to populate
itself. Therefore, a...
|
by: Devin Wood |
last post by:
Hi,
I have a page with a ListBox on it, and It's also have a some buttons to
populate the ListBox by using JavaScript.
I have no problem with populate the listbox using JavaScript. But when the
page is submited / postback, the listbox is still empty.
Do you have any solution for this case (if I still want to use ListBox
Server Control) ?
| |
by: Dave |
last post by:
Hi All,
I have a windows form that contains 2 listboxes and 2 buttons.
The listbox on the right is populated by a database routine (This is the
easy part).
The listbox on the left is populated by 1 or more selected items from the
listbox on the right after clicking an Add button.
Clicking a "Remove" button will remove the item from the left listbox and
restore it back to the right box.
|
by: Joe Blow |
last post by:
Folks,
I have read all the posts about databases I could find and I think I
need a little more help. I want to take all the items from a field in
an access database and use them as list items in a list box. Let's say
the listbox is called listAddress, the database is address.mdb, the
table is tblName and the field is fieldName.
Could someone give me code to populate the listbox? I only need it
populated once, I don't need to update...
|
by: Chaihana Joe |
last post by:
Hi
I'm trying to populate a listbox as a value list in code (access
2003).
Unfortunately I'm getting 'runtime error 2176 - the setting for this
property is too long' somewhere around the 2000 character mark.
Searching on the web I've seen mention that there is a limit of 2048
characters for a value list and that a workaround is to use a function
|
by: dbuchanan |
last post by:
I intend to populate a listBox from the database for later use. (the intent
for doing this is irrelevant to this questrion)
The list box when hidden is never populated. The list box when visible is
always populatd. How do I populate it even though it remains hidden?
Thanks,
Doug
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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();...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |