C#:
private void listBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
Drop(e);
}
void Drop(DragEventArgs e)
{
this.listBox1.SelectedIndexChanged -= new System.EventHandler(this.listBox1_SelectedIndexChanged);
this.timer.Enabled=false;
string[]oldV=new String[this.listBox1.Items.Count];
for(int i=0; i < oldV.Length; i++)
{
oldV[i]= i+1+"";
}
string[]newV=new String[this.listBox1.Items.Count];
for(int i=DragIndex; i >= 0; i--)
{
//MessageBox.Show(i+" --"+(this.selIndex+1));
if(i==DragIndex)
newV[i]= this.selIndex+1+"";
else
newV[i]= i+1+"";
}
for(int i=DragIndex; i <= newV.Length-DragIndex+1; i++)
{
//MessageBox.Show(i+" ++"+(this.selIndex+1));
if(i==DragIndex)
newV[i]= this.selIndex+1+"";
else
newV[i]= i+1+"";
}
/*THIS IS WHERE THE CODE STOPS*/
bool ok= a.registry.RenameRegValues(ref ImageKey, oldV, newV);
if(!ok) MessageBox.Show("not ok");
this.listBox1.Items.Remove(this.listBox1.Items[selIndex]);
string[] s= (string[])e.Data.GetData(typeof(string[]));
this.listBox1.Items.Insert(DragIndex, s[0]);
this.timer.Enabled=true;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
}
Is this normal? Is there a way around it?