GrapeCity MultiRow Windows Forms Documentation
CellMouseDown Event
Example 


Occurs when the user presses a mouse button while the mouse pointer is within the boundaries of a cell.
Syntax
<SRDescriptionAttribute("Occurs when the user presses a mouse button while the mouse pointer is within the boundaries of a cell.")>
<SRCategoryAttribute("Mouse")>
Public Event CellMouseDown As EventHandler(Of CellMouseEventArgs)
Dim instance As GcMultiRow
Dim handler As EventHandler(Of CellMouseEventArgs)
 
AddHandler instance.CellMouseDown, handler
[SRDescription("Occurs when the user presses a mouse button while the mouse pointer is within the boundaries of a cell.")]
[SRCategory("Mouse")]
public event EventHandler<CellMouseEventArgs> CellMouseDown
Event Data

The event handler receives an argument of type CellMouseEventArgs containing data related to this event. The following CellMouseEventArgs properties provide information specific to this event.

PropertyDescription
Button (Inherited from System.Windows.Forms.MouseEventArgs)
CellIndexGets the cell index in its parent Section.  
CellNameGets the cell name.  
Clicks (Inherited from System.Windows.Forms.MouseEventArgs)
Delta (Inherited from System.Windows.Forms.MouseEventArgs)
Location (Inherited from System.Windows.Forms.MouseEventArgs)
RowIndexGets the index of the owner Row that the event occurs for.  
ScopeGets the cell area that the event occurs for.  
SectionIndexGets the index of the owner Section that the event occurs for.  
X (Inherited from System.Windows.Forms.MouseEventArgs)
Y (Inherited from System.Windows.Forms.MouseEventArgs)
Remarks
Mouse events occur in the following order:
  1. CellMouseEnter
  2. CellMouseMove
  3. CellMouseDown
  4. CellMouseUp
  5. CellMouseLeave
Example
The following code example shows how to hide the clicked row when the ContextMenuStrip pops up on the RowHeaderCell. You can execute cut, copy, and paste with the ContextMenuStrip.
void gcMultiRow1_CellMouseDown(object sender, CellMouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (e.Scope == CellScope.Row && gcMultiRow1.Template.Row.Cells[e.CellIndex].Selectable)
                {
                    gcMultiRow1.CurrentCellPosition = new CellPosition(e.Scope, e.SectionIndex, e.CellIndex);
                }
                if (gcMultiRow1.GetValue(e.SectionIndex, e.CellIndex) != null)
                {
                    cut.Enabled = true;
                    copy.Enabled = true;
                }
                else
                {
                    cut.Enabled = false;
                    copy.Enabled = false;
                }

                if (e.Scope == CellScope.Row && e.SectionIndex != gcMultiRow1.RowCount - 1)
                {
                    sectionMenuStrip.Enabled = true;
                    sectionMenuStrip.Tag = new CellPosition(e.Scope, e.SectionIndex, e.CellIndex);
                }
                else
                {
                    sectionMenuStrip.Enabled = false;
                }

                if (Clipboard.ContainsText())
                {
                    paste.Enabled = true;
                }
                else
                {
                    paste.Enabled = false;
                }
            }
        }
Private Sub gcMultiRow1_CellMouseDown(ByVal sender As Object, ByVal e As CellMouseEventArgs) Handles gcMultiRow1.CellMouseDown
        If e.Button = MouseButtons.Right Then
            If e.Scope = CellScope.Row AndAlso gcMultiRow1.Template.Row.Cells(e.CellIndex).Selectable Then
                gcMultiRow1.CurrentCellPosition = New CellPosition(e.Scope, e.SectionIndex, e.CellIndex)
            End If
            If gcMultiRow1.GetValue(e.SectionIndex, e.CellIndex) <> Nothing Then
                cut.Enabled = True
                copy.Enabled = True
            Else
                cut.Enabled = False
                copy.Enabled = False
            End If

            If e.Scope = CellScope.Row AndAlso e.SectionIndex <> gcMultiRow1.RowCount - 1 Then
                sectionMenuStrip.Enabled = True
                sectionMenuStrip.Tag = New CellPosition(e.Scope, e.SectionIndex, e.CellIndex)
            Else
                sectionMenuStrip.Enabled = False
            End If

            If Clipboard.ContainsText() Then
                paste.Enabled = True
            Else
                paste.Enabled = False
            End If
        End If
    End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

GcMultiRow Class
GcMultiRow Members

 

 


Copyright © GrapeCity, inc. All rights reserved.