Dear all,
My solution have a form with checkedlistbox and two button (Move Up, Move Down). I want to move up/down items in checkedlistbox when i push buttons up or down or drag and drop items possible.
This is my code :
private void btnMoveUp_Click(object sender, EventArgs e)
{
chkListBox.SelectedIndex -= 1;
} private void btnMoveDown_Click(object sender, EventArgs e)
{
chkListBox.SelectedIndex += 1;
}
please help me add code to move.
Thanks for cooperation.
Khiem Vo.

Move or Drap and Drop items in CheckedListBox VS.Net 2005
Demian Schnaidman
Your code is helpful I got it, however i would like flexible drag and drop items. Please help me again.
Thanks for your help. I looking forward to hearing from u.
Khiem Vo.
lgbjr
private void btnUp_Click(object sender, EventArgs e) {
int index = clbItems.SelectedIndex;
if(index > 0) {
MoveItem(-1);
}
}
int index = clbItems.SelectedIndex;
if(index < clbItems.Items.Count - 1) {
MoveItem(1);
}
}
int index = clbItems.SelectedIndex;
object item = clbItems.SelectedItem;
// Checked state is lost when you remove and re-insert the item
bool isChecked = clbItems.GetItemChecked(index);
clbItems.Items.Remove(item);
clbItems.Items.Insert(index + step, item);
clbItems.SetItemChecked(index + step, isChecked);
}