CheckedListBox のドラッグ ドロップ並べ替え関数を実装しました。下部の外側にドラッグすると下にスクロールし、上部でその逆をドラッグする場合(通常のドラッグドロップ自動スクロール)
たくさんの WPF 情報を見つけましたが、それらのソリューションを winform ChekedListBox に適用する方法がわかりません。
これが私のコードです:
private void myListBox_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
Point point = myListBox.PointToClient(new Point(e.X, e.Y));
int index = myListBox.IndexFromPoint(point);
int selectedIndex = myListBox.SelectedIndex;
if (index < 0)
{
index = selectedIndex;
}
if (index != selectedIndex)
{
myListBox.SwapItems(selectedIndex, index);
myListBox.SelectedIndex = index;
}
}