Listbox da girilen itemi, yukarı,aşağı kaydırma, işlemini gerçekleştirme işlemi. Listbox’da kullanıcı girdiği veya girilen itemin sırasını, önceliğini belirlemesi için kullanabileceğiniz bir örnek.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | private void KategoriListeYukariTasiButon_Click(object sender, EventArgs e) { try { int index = KategorilerListe.SelectedIndex; if (index > 0 & index != -1) { KategorilerListe.Items.Insert(index - 1, KategorilerListe.Items[index]); KategorilerListe.Items.RemoveAt(index + 1); KategorilerListe.SelectedIndex = index - 1; } } catch { } } private void KategoriListeAsagiTasiButon_Click(object sender, EventArgs e) { try { int index = KategorilerListe.SelectedIndex; if (index != -1 & index < KategorilerListe.Items.Count - 1) { KategorilerListe.Items.Insert(index + 2, KategorilerListe.Items[index]); KategorilerListe.Items.RemoveAt(index); KategorilerListe.SelectedIndex = index + 1; } } catch { } } |