※ 引述《datagram (...)》之銘言:
: 我有一個 ListBox 上面可以新增許多名單
: 又另設了一個Button 可以刪除在ListBox上 所選取的某名單
: 這個 Button裡面要怎麼寫指令 試了好久還是不成功 = =
: 應該是 ListBox.*** = *** 的嗎?
: 之前講的VB文章好像不適用
: 感謝...
Me.ListBox1.Items.Remove(Me.ListBox1.SelectedItem)
'or
Me.ListBox1.Items.RemoveAt(Me.ListBox1.SelectedIndex)
ListBox1.SelectedItem → 抓到選取的Item
ListBox1.Items.Remove → 傳入選取的item,刪除item
ListBox1.SelectedIndex → 抓到選取的Item 位在listbox中的打一個位置
Me.ListBox1.Items.RemoveAt → 依照選取的item位置,刪除item
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.184.51.8