Bu fonksiyonu kullanabilirsiniz. Aşağı ve yukarı butonları şekildeki gibi çağırabilirsiniz. Buttondown ilgili ögeyi aşağıya indirecektir. ButtonUp ilgili ögeyi yukarı taşıyacaktır. protected void ButtonDown_Click(object sender, EventArgs e) { MoveListboxItem(1, ListBox2); } protected void ButtonUp_Click(object sender, EventArgs e) { MoveListboxItem(-1, ListBox2); } private void MoveListboxItem(int index, ListBox listBox) { if (listBox.SelectedIndex != -1) //is there an item selected? { //if it's moving up, the loop moves from first to last, otherwise, it moves from last to first for (int i = (index < 0 ? 0 : listBox.Items.Count - 1); index < 0 ? i < listBox.Items.Count : i > -1; i -= index) { if (listBox.Items[i].Selected) { //if it's moving up, it should not be the first item, or, if it's moving down, it should no
Yorumlar
Yorum Gönder