DataGrid::OnMouseDown Method (MouseEventArgs^)

 

Raises the MouseDown event.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

protected:
virtual void OnMouseDown(
	MouseEventArgs^ e
) override

Parameters

e
Type: System.Windows.Forms::MouseEventArgs^

A MouseEventArgs that contains data about the OnMouseDown event.

Raising an event invokes the event handler through a delegate. For an overview, see NIB: Raising an Event.

Notes to Inheritors:

When overriding OnMouseDown in a derived class, be sure to call the base class's OnMouseDown method.

The following code example demonstrates the use of this member.

public ref class MyDataGrid: public DataGrid
{
protected:

   // Override the OnMouseDown event to select the whole row
   // when the user clicks anywhere on a row.
   virtual void OnMouseDown( MouseEventArgs^ e ) override
   {

      // Get the HitTestInfo to return the row and pass
      // that value to the IsSelected property of the DataGrid.
      DataGrid::HitTestInfo ^ hit = this->HitTest( e->X, e->Y );
      if ( hit->Row < 0 )
               return;

      if ( this->IsSelected( hit->Row ) )
               UnSelect( hit->Row );
      else
               Select(hit->Row);
   }
};

.NET Framework
Available since 1.1
Return to top
Show: