Get the App
SLTechnology News&Howtos  ›  Development  › 

How to add and remove operations to ListBox implementations

Shulou Source: shulou.com Published: 2022-06-03 05:43:09 11月17日 Update

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

Tags: Code article more good practical successful content writing foreground background multiple article method time knowledge index index number this is error reference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple Docker Shulou Tech Info Huawei