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

how to get multi select values from listbox???


HI there

I make a data binding for list box, and it is multi selects, everything
working fine, but How can I get the multi select values in windows form?

I try many ways for HolidaysListBox.SelectedValue to get mult selected
values, but it looks not work for me, anyone has an idea for this?
Thanks

Tony

code as follow

Dim HolidayDS As New DataSet("dsHolidays")
Dim HolidayDT As DataTable = HolidayDS.Tables.Add("dtHolidays")
'Add columns to dataset
Dim pkCol As DataColumn = HolidayDT.Columns.Add("HolidayDate",
Type.GetType("System.String"))
HolidayDT.Columns.Add("HolidayName", Type.GetType("System.String"))
HolidayDT.PrimaryKey = New DataColumn() {pkCol}
Dim HolidayRow As DataRow
HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "01/01" 'January 1st
HolidayRow.Item(1) = "New Year's Day"
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "02/12" 'February 12th
HolidayRow.Item(1) = "Abraham(Lincoln) 's Birthday"
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "02/14" 'February 14th
HolidayRow.Item(1) = "St.Valentine() 's Day"
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "02/22" 'February 22nd
HolidayRow.Item(1) = "George(Washington) 's Birthday"
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "03/17" 'March 17th
HolidayRow.Item(1) = "St.Patrick() 's Day"
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "" 'Empty row
HolidayRow.Item(1) = ""
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidaysListBox.ValueMember = "HolidayDate"
HolidaysListBox.DisplayMember = "HolidayName"
HolidaysListBox.DataSource =
HolidayDS.Tables("dtHolidays").DefaultView

?
Nov 20 '05 #1
2 1763
Hi,

Look at the listbox SelectedItems.

Ken
-----------------------
"Tony Dong" <it****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

HI there

I make a data binding for list box, and it is multi selects, everything
working fine, but How can I get the multi select values in windows form?

I try many ways for HolidaysListBox.SelectedValue to get mult selected
values, but it looks not work for me, anyone has an idea for this?
Thanks

Tony

code as follow

Dim HolidayDS As New DataSet("dsHolidays")
Dim HolidayDT As DataTable = HolidayDS.Tables.Add("dtHolidays")
'Add columns to dataset
Dim pkCol As DataColumn = HolidayDT.Columns.Add("HolidayDate",
Type.GetType("System.String"))
HolidayDT.Columns.Add("HolidayName", Type.GetType("System.String")) HolidayDT.PrimaryKey = New DataColumn() {pkCol}
Dim HolidayRow As DataRow
HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "01/01" 'January 1st
HolidayRow.Item(1) = "New Year's Day"
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "02/12" 'February 12th
HolidayRow.Item(1) = "Abraham(Lincoln) 's Birthday"
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "02/14" 'February 14th
HolidayRow.Item(1) = "St.Valentine() 's Day"
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "02/22" 'February 22nd
HolidayRow.Item(1) = "George(Washington) 's Birthday"
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "03/17" 'March 17th
HolidayRow.Item(1) = "St.Patrick() 's Day"
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidayRow = HolidayDS.Tables("dtHolidays").NewRow
HolidayRow.Item(0) = "" 'Empty row
HolidayRow.Item(1) = ""
HolidayDS.Tables("dtHolidays").Rows.Add(HolidayRow )

HolidaysListBox.ValueMember = "HolidayDate"
HolidaysListBox.DisplayMember = "HolidayName"
HolidaysListBox.DataSource =
HolidayDS.Tables("dtHolidays").DefaultView

?

Nov 20 '05 #2
Hi Ken

When I use listbox.selectedItems and add it to arraylist, and then use a
loop to show it, it show me
System.Data.DataRowview, not the valuemember's value

Tony

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

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

Similar topics

6
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on...
3
by: yb | last post by:
I have a unbound mult-select listbox field named "Locations".Multi-select option is set to "Extended". I'm having problem saving the values from this field into table. I have text column...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
2
by: Zlatko Matić | last post by:
Hello. How to reference selected values from a multi-select list box, as a criteria in a query ? Is it possible at all? Regards, Zlatko
5
by: Matthew Wells | last post by:
I have a listbox set to simple multi select. For this example, users only select one item at a time. I have command buttons on the form for First, Previous, Next, Last, New (record). The form...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
0
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a ListBox server control named "lb_dates" with a SelectionMode of "Multiple". The user can select multiple dates from the listbox. I have ObjectDataSource named "ods_rfq" with a...
36
by: aaronkmar | last post by:
Hello Bytes, I've been a long time lurker, there so much information here I always find my answers with ease. Until today... I'm hoping someone can exert a little brain power for me. I have...
11
by: woodey2002 | last post by:
This problem is driving me crazy. Hello there, i am trying to create a search form for records in my access database. The search form will contain text boxes and a multi select list box. The user...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.