Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

MouseDown Event procedure on Drag Drop routines

$
0
0

Hello Everyone:

I'm trying to drag drop employee records from one DataGridView to another DataGridView:

Following is the MouseDown event routine from the Unassigned Employee Grid View

private void Unassigned_dataVW_MouseDown(object sender, MouseEventArgs e)        {            // test to make sure the user has selected a value, before submitting value to a variable.            if (this.Unassigned_dataVW.SelectedRows != null)            {                // Grab selected value and "cast" it to an integer                int rowIndx = Convert.ToInt32(this.Unassigned_dataVW.SelectedCells[0].RowIndex);                EmployeeID = Convert.ToInt32(this.Unassigned_dataVW[0, rowIndx].Value);                Console.Write(".. Leaving mouse down: " + EmployeeID);                // Feed EmployeeID to DragDropEffects - so that it can be carried to receiving station               DragDropEffects dde1 = DoDragDrop(EmployeeID, DragDropEffects.All);            }            else            {                return;            }        }

The routine essentially works, but the routine is picking up the EmployeeID of the record already selected BEFORE the employee did a "mouse down" on the current record selector.

I've tried putting this routine in the following event procedures:

  1. SelectionChanged
  2. RowHeaderMouseClick
  3. MouseClicke

Those are just some of the events I try to use. None of them work.

I've tried resetting the EmployeeID variable to 0 BEFORE this statement:

EmployeeID = Convert.ToInt32(this.Unassigned_dataVW[0, rowIndx].Value);  

But resetting to 0, before grabbing new EmployeeID still outputs id of previous record.

Any suggestions on how to grab the correct id BEFORE dragging and dropping are welcome. All too often, it is possible for a user to select, drag the wrong unassigned employee and drop them in a new station DataGridView.

Thanks in advance - Pavilion



Viewing all articles
Browse latest Browse all 12583

Trending Articles