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

Listbox

Hi,

I want to pass the values that have been chosen from a
few comboboxes into a listbox as a single entry.

how do i do this??

this is what i tried... it will probably give u some
indication of what im trying to achieve:

Dim ChosenDate As Date
ChosenDate = dtpRoomDate.Value()
Dim ChosenRoom As String
ChosenRoom = CBoxRoomNames.SelectedItem
Dim ChosenLayout As String
ChosenLayout = CBoxLayout.SelectedItem
Dim ChosenSession As String
ChosenSession = CBoxSession.SelectedItem
Dim ChosenGuestNo As Int32
ChosenGuestNo = txtNoOfGuests.Text

LBoxSelRooms.Items.Add(ChosenDate, ChosenRoom,
ChosenLayout, ChosenSession, ChosenGuestNo)
of course this does not work!! I want all the values
passed into the same row. is this possible or would i be
better off using another control?

Thx for your time

Jul 21 '05 #1
2 2172
First, if you want the data to appear in separate columns, use a ListView control with the view property set to View.Details. I
think you're saying you want everything to appear as a single string in one column, though. In this case, using a ListBox will
work. One way to acheive this is to format all the data you want to add to the list box as a single string, and then add this
string to the listbox. For example, you could modify your call to LBoxSelRooms.Items.Add as follows:

Dim FullDescription As String
FullDescription = String.Format("{0}, {1}, {2}, {3}, {4}", ChosenDate, ChosenRoom, ChosenLayout, ChosenSession,
ChosenGuestNo)
LBoxSelRooms.Items.Add(FullDescription)

To modify how the data appears, change the formatting string in the above call to String.Format.

Another slightly more complex approach would be to create a class to encapsulate the data you want to add, and then
override the ToString method in this class to return the formatted string you want to appear in the list box. You would then
create an instance of this class and add it to the listbox. If you need to pass this information to other parts of your
application, this approach could result in cleaner, more maintainable code.

Thanks,
Grayson

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| >Content-Class: urn:content-classes:message
| >From: "Luna" <s@u>
| >Sender: "Luna" <s@u>
| >Subject: Listbox
| >Date: Sun, 16 Nov 2003 04:31:30 -0800
| >Lines: 31
| >Message-ID: <04****************************@phx.gbl>
| >MIME-Version: 1.0
| >Content-Type: text/plain;
| > charset="iso-8859-1"
| >Content-Transfer-Encoding: 7bit
| >X-Newsreader: Microsoft CDO for Windows 2000
| >X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >Thread-Index: AcOsPZASt/3KcVMcQTaF6Giop2UJOA==
| >Newsgroups: microsoft.public.dotnet.general
| >Path: cpmsftngxa06.phx.gbl
| >Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:115760
| >NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| >X-Tomcat-NG: microsoft.public.dotnet.general
| >
| >Hi,
| >
| >I want to pass the values that have been chosen from a
| >few comboboxes into a listbox as a single entry.
| >
| >how do i do this??
| >
| >this is what i tried... it will probably give u some
| >indication of what im trying to achieve:
| >
| >Dim ChosenDate As Date
| > ChosenDate = dtpRoomDate.Value()
| > Dim ChosenRoom As String
| > ChosenRoom = CBoxRoomNames.SelectedItem
| > Dim ChosenLayout As String
| > ChosenLayout = CBoxLayout.SelectedItem
| > Dim ChosenSession As String
| > ChosenSession = CBoxSession.SelectedItem
| > Dim ChosenGuestNo As Int32
| > ChosenGuestNo = txtNoOfGuests.Text
| >
| >LBoxSelRooms.Items.Add(ChosenDate, ChosenRoom,
| >ChosenLayout, ChosenSession, ChosenGuestNo)
| >
| >
| >of course this does not work!! I want all the values
| >passed into the same row. is this possible or would i be
| >better off using another control?
| >
| >Thx for your time
| >
| >
Jul 21 '05 #2
Hi,

If i use the listbox,can i still refence the coloumns
indivually afterwords or will all the columns be stored
as one long string?

I need to be able to access each individual column after
they have been put into the listbox (or any other control
that u reccomend).

thx
-----Original Message-----
First, if you want the data to appear in separate columns, use a ListView control with the view property
set to View.Details. Ithink you're saying you want everything to appear as a single string in one column, though. In this case, using
a ListBox willwork. One way to acheive this is to format all the data you want to add to the list box as a single string, and
then add thisstring to the listbox. For example, you could modify your call to LBoxSelRooms.Items.Add as follows:
Dim FullDescription As String
FullDescription = String.Format("{0}, {1}, {2}, {3}, {4}", ChosenDate, ChosenRoom, ChosenLayout,
ChosenSession,ChosenGuestNo)
LBoxSelRooms.Items.Add(FullDescription)

To modify how the data appears, change the formatting string in the above call to String.Format.
Another slightly more complex approach would be to create a class to encapsulate the data you want to add,
and thenoverride the ToString method in this class to return the formatted string you want to appear in the list box. You
would thencreate an instance of this class and add it to the listbox. If you need to pass this information to other
parts of yourapplication, this approach could result in cleaner, more maintainable code.
Thanks,
Grayson

This posting is provided "AS IS" with no warranties, and confers no rights.--------------------
| >Content-Class: urn:content-classes:message
| >From: "Luna" <s@u>
| >Sender: "Luna" <s@u>
| >Subject: Listbox
| >Date: Sun, 16 Nov 2003 04:31:30 -0800
| >Lines: 31
| >Message-ID: <04****************************@phx.gbl>
| >MIME-Version: 1.0
| >Content-Type: text/plain;
| > charset="iso-8859-1"
| >Content-Transfer-Encoding: 7bit
| >X-Newsreader: Microsoft CDO for Windows 2000
| >X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300| >Thread-Index: AcOsPZASt/3KcVMcQTaF6Giop2UJOA==
| >Newsgroups: microsoft.public.dotnet.general
| >Path: cpmsftngxa06.phx.gbl
| >Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:115760| >NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| >X-Tomcat-NG: microsoft.public.dotnet.general
| >
| >Hi,
| >
| >I want to pass the values that have been chosen from a| >few comboboxes into a listbox as a single entry.
| >
| >how do i do this??
| >
| >this is what i tried... it will probably give u some
| >indication of what im trying to achieve:
| >
| >Dim ChosenDate As Date
| > ChosenDate = dtpRoomDate.Value()
| > Dim ChosenRoom As String
| > ChosenRoom = CBoxRoomNames.SelectedItem
| > Dim ChosenLayout As String
| > ChosenLayout = CBoxLayout.SelectedItem
| > Dim ChosenSession As String
| > ChosenSession = CBoxSession.SelectedItem
| > Dim ChosenGuestNo As Int32
| > ChosenGuestNo = txtNoOfGuests.Text
| >
| >LBoxSelRooms.Items.Add(ChosenDate, ChosenRoom,
| >ChosenLayout, ChosenSession, ChosenGuestNo)
| >
| >
| >of course this does not work!! I want all the values
| >passed into the same row. is this possible or would i be| >better off using another control?
| >
| >Thx for your time
| >
| >
.

Jul 21 '05 #3

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

Similar topics

17
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
3
by: Paul T. Rong | last post by:
I have a listbox (of product names) control on my form. I want to pass the selected item (a product name) to a subform, and the product unitprice should apear automatically next to the product name...
8
by: Oddball | last post by:
Ok - I have a ListBox control and I'm ready to write my own DrawItem event handler. What I want to draw as the item is another control. I have created a user control that I would like to list in...
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
1
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
3
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
5
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.