473,396 Members | 1,875 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,396 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 2179
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.