T
Tony Dong
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
?
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
?