How to add and remove operations to ListBox implementations
This article will explain in detail how to add and remove operations to the ListBox implementation. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Foreground code:
The code is as follows:
Tom
Jion
J
L
K
Background code:
The code is as follows:
Protected void btnAdd_Click (object sender, EventArgs e)
{
# A misunderstanding of adding records in region listbox
/ / when multiple records are selected, one is not added, because when one record is removed, the index of the original second record is 0
/ / for (int I = 0; I < ListBox1.Items.Count; iTunes +)
/ / {
/ / if (ListBox1.Items [I] .Selected = true)
/ / {
/ / ListBox2.Items.Add (ListBox1.SelectedValue)
/ / ListBox1.Items.Remove (ListBox1.SelectedValue)
/ /}
/ /}
# endregion
# simple way to add region listbox using index index number
/ / while (0 = 0; iMurray -)
{
If (ListBox1.Items [I] .Selected = = true)
{
List.Add (ListBox1.Items [I])
ListBox1.Items.Remove (ListBox1.Items [I])
}
}
For (int I = 0; I