private void DownLoadOrder_Click(object sender, EventArgs e) { if (LoadOrderList.SelectedIndex <= 0 || LoadOrderList.SelectedIndex == LoadOrderList.Items.Count - 1) { return; } int Index = LoadOrderList.SelectedIndex; int IndexBelow = Index + 1; var item = LoadOrderList.Items[Index]; bool isChecked = LoadOrderList.GetItemChecked(Index); var itemBelow = LoadOrderList.Items[IndexBelow]; bool isCheckedBelow = LoadOrderList.GetItemChecked(IndexBelow); LoadOrderList.Items[IndexBelow] = item; LoadOrderList.SetItemChecked(IndexBelow, isChecked); LoadOrderList.Items[Index] = itemBelow; LoadOrderList.SetItemChecked(Index, isCheckedBelow); LoadOrderList.SelectedIndex++; }
private void button1_Click(object sender, EventArgs e) { if (LoadOrderList.SelectedIndex <= 0) { return; } int Index = LoadOrderList.SelectedIndex; if (LoadOrderList.GetItemChecked(Index) == false) { LoadOrderList.SetItemChecked(Index, true); } else { LoadOrderList.SetItemChecked(Index, false); } }
private void UpLoadOrder_Click(object sender, EventArgs e) { if (LoadOrderList.SelectedIndex <= 1) { return; } int Index = LoadOrderList.SelectedIndex; int IndexAbove = Index - 1; var item = LoadOrderList.Items[Index]; bool isChecked = LoadOrderList.GetItemChecked(Index); var itemAbove = LoadOrderList.Items[IndexAbove]; bool isCheckedAbove = LoadOrderList.GetItemChecked(IndexAbove); LoadOrderList.Items[IndexAbove] = item; LoadOrderList.SetItemChecked(IndexAbove, isChecked); LoadOrderList.Items[Index] = itemAbove; LoadOrderList.SetItemChecked(Index, isCheckedAbove); LoadOrderList.SelectedIndex--; }