Instructions: Create list box that allows the user to select more than one item at a time. First program single button (which I did successfully-shown below) then program multi button when selection mode property is set to MultiExtended. It says to do that by clearing the contects of the Result Label but when I do that it just makes that label blank when I click on multi button. The result should have all the names selected on seperate lines in the Result Label.
This is what I have so far:
Private Sub MultiForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'fills the list box with data
Me.uiNamesListBox.Items.Add("Ahmad")
Me.uiNamesListBox.Items.Add("Jim")
Me.uiNamesListBox.Items.Add("Debbie")
Me.uiNamesListBox.Items.Add("Jeanne")
Me.uiNamesListBox.Items.Add("Bill")
End Sub
Private Sub uiSingleButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uiSingleButton.Click
Dim name As String
name = Me.uiNamesListBox.Text
Call DisplayName(name)
End Sub
Private Sub DisplayName(ByVal name As String)
Me.uiResultLabel.Text = name
End Sub
create list box
Page 1 of 11 Replies - 6799 Views - Last Post: 17 November 2005 - 02:40 PM
Replies To: create list box
#2
Re: create list box
Posted 17 November 2005 - 02:40 PM
This is what i did for the multi button's click even procedure. I believe we are talking about the exact same problem from the exact same book.
Private Sub uiMultiButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uiMultiButton.Click
Dim count As Integer
Me.uiResultLabel.Text = ""
For count = 1 To Me.uiNamesListBox.SelectedItems.Count
Me.uiResultLabel.Text = Me.uiResultLabel.Text & Convert.ToString(Me.uiNamesListBox.SelectedItems(count - 1)) & ControlChars.NewLine
Next count
End Sub
Let me know if you have a question. Have fun.
DaArmy
Private Sub uiMultiButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uiMultiButton.Click
Dim count As Integer
Me.uiResultLabel.Text = ""
For count = 1 To Me.uiNamesListBox.SelectedItems.Count
Me.uiResultLabel.Text = Me.uiResultLabel.Text & Convert.ToString(Me.uiNamesListBox.SelectedItems(count - 1)) & ControlChars.NewLine
Next count
End Sub
Let me know if you have a question. Have fun.
DaArmy
This post has been edited by DaArmy: 17 November 2005 - 03:11 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|