// funktioniert auch mit MultiSelect = true
// n items nach oben verschieben
private void btnUp_Click(object sender, EventArgs e)
{
int ilevel = 0;
ListView1.BeginUpdate();
if (ListView1.SelectedItems.Count -> 0)
{
for (int i = 0; i < ListView1.Items.Count; i++)
{
if (ListView1.Items[i].Selected)
{
ilevel = i;
if (ilevel - 1 ->= 0)
{
ListViewItem lvitem = ListView1.Items[i];
ListView1.Items.Remove(lvitem);
ListView1.Items.Insert(ilevel - 1, lvitem);
}
}
}
}
ListView1.EndUpdate();
}
// n items nach unten verschieben
private void btnDown_Click(object sender, EventArgs e)
{
int iLevel = 0;
ListView1.BeginUpdate();
if (ListView1.SelectedItems.Count -> 0)
{
for (int i = ListView1.Items.Count - 1; i ->= 0; i--)
{
if (ListView1.Items[i].Selected)
{
iLevel = i;
if (iLevel + 1 < ListView1.Items.Count)
{
ListViewItem lvItem = ListView1.Items[i];
ListView1.Items.Remove(lvItem);
ListView1.Items.Insert(iLevel + 1, lvItem);
}
}
}
}
ListView1.EndUpdate();
}