473,944 Members | 3,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fill Listbox

I would like to fill a listbox with a 2 column valuelist and hide the value
in the first column as available in VBA. I have tried .items.add and
item.addrange but cannot seem to get the desired result. I am using the form
Load event to fill the listbox.
Regards
Feb 4 '07 #1
5 1746
"Terry" <ne*******@whit eHYPHENlightDOT me.ukschrieb:
>I would like to fill a listbox with a 2 column valuelist and hide the value
in the first column as available in VBA. I have tried .items.add and
item.addrang e but cannot seem to get the desired result. I am using the
form Load event to fill the listbox.
Add the items to a "collection " ('DataTable', for example), assign it to the
control's 'DataSource' property and set its 'DisplayMember' and
'ValueMember' properties according to your needs.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 4 '07 #2
Its not very often I agree with Herfried, but I do in this situation.

OMG! I am slipping! Help!!!!!!!!!!! !!!!!!!!!!!

--
Newbie Coder
(It's just a name)
Feb 5 '07 #3
Terry,

For this you have to fill class objects to the itemlist from a listbox.

You have to cast those when you need them. In fact you can use endless
columns.

(I normally give always the samples of datatables and than comes Herfried
with this class/object answer, I was supprised that he gave now my standard
answer).

Cor

"Terry" <ne*******@whit eHYPHENlightDOT me.ukschreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>I would like to fill a listbox with a 2 column valuelist and hide the value
in the first column as available in VBA. I have tried .items.add and
item.addrang e but cannot seem to get the desired result. I am using the
form Load event to fill the listbox.
Regards

Feb 5 '07 #4
On Feb 5, 6:22 am, "Terry" <news-g...@whiteHYPHE NlightDOTme.ukw rote:
I would like to fill a listbox with a 2 column valuelist and hide the value
in the first column as available in VBA. I have tried .items.add and
item.addrange but cannot seem to get the desired result. I am using the form
Load event to fill the listbox.
Regards
Me.myList.Items .Add(New ListItem("My_Di splay_Text",
"My_Hidden_Valu e"))

The Grand Master

Feb 5 '07 #5
Thanks for all the help.

I have decided to use a small SQL table which will allow me to easily add
new rows without having to re-code. I had needed to create the database for
this project so have taken this opportunity to learn something about
SQL2005.

Regards
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:ew******** ******@TK2MSFTN GP03.phx.gbl...
Terry,

For this you have to fill class objects to the itemlist from a listbox.

You have to cast those when you need them. In fact you can use endless
columns.

(I normally give always the samples of datatables and than comes Herfried
with this class/object answer, I was supprised that he gave now my
standard answer).

Cor

"Terry" <ne*******@whit eHYPHENlightDOT me.ukschreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>>I would like to fill a listbox with a 2 column valuelist and hide the
value in the first column as available in VBA. I have tried .items.add and
item.addran ge but cannot seem to get the desired result. I am using the
form Load event to fill the listbox.
Regards


Feb 6 '07 #6

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

Similar topics

9
4003
by: Harlin Seritt | last post by:
I am trying the following: Listbox(parent).pack(fill=BOTH, expand=YES) I notice that the listbox will fill on the X axis but will not on the Y axis unlike other widgets. Is there any way to force this? thanks, Harlin
9
7036
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with the selected record in the listbox.
3
12084
by: ali poursadri | last post by:
Hi, I want to fill my list box from a dataset in c#. I use adapter and fill command and bind it to a listbox, but it is very slow for large data about 500000 records. How can I view this list rapid? thanks.
3
5696
by: Hrvoje Voda | last post by:
How to Fill a listbox with data from database? Hrcko
0
307
by: Abra | last post by:
Is it possible to fill a ADO.NET dataset incrementally ? (I mean to call the DataAdapter Fill() method several times, as I did not found a Add() method) I would like to call in a background thread the Fill method several times, only with a limited number of records, as I have very many records in the database. The dataset is attached to a control (listbox) and I would like that the listbox appears quickly on screen with some 50 records...
6
1993
by: William Sullivan | last post by:
I want to fill a cell in a table with a control. Lets say the control is a listbox--something that you'd think would easily fill a cell, which would be a good thing. So I create the table and stick the control inside, setting its width and height to 100%. When I run the application, the control appears to be an arbitrary size, each edge a different distance from its relative edge. So, I go into the properties for the cell and set all...
3
6433
by: Rich | last post by:
Hello, I am just starting out with VB.net. I need to fill a listbox with data from an MS Access mdb file. What I tried was to create/add an ole connection object, then added an ole adapter object and an command object (the commandtext is "Select * from table1"), then added a dataset object. So I got as far as doing something like this in a button:
1
7545
by: Steve Richter | last post by:
I have a form. In the Form is a MenuStrip and a FlowLayoutPanel. In the FlowLayoutPanel is a ListBox. The FlowLayoutPanel is set to DockStyle.Fill. The ListBox is set to AnchorStyles.Left | AnchorStyles.Right I am able to verify that the FlowLayoutPanel grows in size as the form
1
2453
by: Peter van der Zee | last post by:
L.S., I'm want to fill a Listbox with class Array "records" based on certain criteria. The idea is to be able to select one "record" at the time, modify the data, and display this "changed" record in the listbox again. On each line of the listbox I want to display various class items. (columns??)
0
10147
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
11547
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
11136
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
11310
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
10677
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
8238
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
6093
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
6315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3520
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.