Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MouseDown vs. DoubleClick

Status
Not open for further replies.

Pumzy

Programmer
Nov 20, 2003
13
JP
Hi people!
I want to ask something about the Event procedures MouseDown and Double click... here it goes:

I have 2 list boxes and i want to be able to drag and drop the item i selected from one listbox to the other. at the same time i want to use the double click event to add items to one of my listboxes.. it seems that only the mousedown event fires and the double click doesnt seem to be executed...
here is my code:

private void lstFieldsAvailable_DoubleClick(object sender, System.EventArgs e)
{
this.lstFieldsSelected.Items.Add( this.lstFieldsAvailable.Items[this.lstFieldsAvailable.SelectedIndex].ToString());
}

private void lstFieldsAvailable_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
try
{
this.lstFieldsAvailable.DoDragDrop(this.lstFieldsAvailable.Text.ToString(),DragDropEffects.Copy);
}
catch
{
return;
}
}

private void lstFieldsSelected_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}

private void lstFieldsSelected_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
this.lstFieldsSelected.Items.Add(this.lstFieldsAvailable.Items[this.lstFieldsAvailable.SelectedIndex].ToString());
}

any help is heartfully appreciated.. tnx! :)

KDjLogan
 
When you doubleclick the mouse button then the MouseDown and MouseUp events are also raised and this is the reason you see the code for MouseDown is executed first.
The something happens with Click and DoubleClick on a control that support both.
You should consume one of them.
-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top