GrapeCity MultiRow Windows Forms Documentation
HitTest(Point) Method
Example 


A System.Drawing.Point that indicates the specified coordinates.
Returns location information, such as section and cell indices.
Syntax
Public Overloads Function HitTest( _
   ByVal point As Point _
) As HitTestInfo
Dim instance As GcMultiRow
Dim point As Point
Dim value As HitTestInfo
 
value = instance.HitTest(point)
public HitTestInfo HitTest( 
   Point point
)

Parameters

point
A System.Drawing.Point that indicates the specified coordinates.

Return Value

A HitTestInfo object that contains the location information.
Example
The following code example shows how to use GcMultiRow's hit test. If you use the right mouse button to click the ColumnHeaderSection, the clicked cell executes an automatic resize. This code example is part of a larger example provided for the HitTestInfo class.
class HitTestDemo : Form
    {
        private GcMultiRow gcMultiRow1 = new GcMultiRow();
        private FlowLayoutPanel panel = new FlowLayoutPanel();
        private Label label = new Label();

        public HitTestDemo()
        {
            this.Text = "HitTest Demo";
            this.Size = new Size(700, 250);

            // Add MultiRow to Form
            this.gcMultiRow1.Dock = DockStyle.Fill;
            this.Controls.Add(this.gcMultiRow1);

            label.Height = 50;
            label.Dock = DockStyle.Bottom;
            label.BackColor = SystemColors.Info;
            label.Text = "Right Click the ColumnHeader, the clicked cell will be auto fitted.";
            this.Controls.Add(label);

            this.Load += new EventHandler(Form1_Load);

            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            gcMultiRow1.Template = Template.CreateGridTemplate(10);
            gcMultiRow1.RowCount = 5;
            gcMultiRow1.MouseClick += new MouseEventHandler(gcMultiRow1_MouseClick);
        }
   
        void gcMultiRow1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                HitTestInfo info = gcMultiRow1.HitTest(e.Location);
                if (info.Type == HitTestType.ColumnHeader)
                {
                    //If right click the ColumnHeader, the clicked cell will execute auto fit.
                    this.gcMultiRow1.ColumnHeaders[info.SectionIndex].Cells[info.CellIndex].PerformHorizontalAutoFit();
                }
                label.Text = info.ToString();
            }
        }
Class HitTestDemo
    Inherits Form
    Friend WithEvents gcMultiRow1 As New GcMultiRow()
    Private panel As New FlowLayoutPanel()
    Private label As New Label()

    Public Sub New()
        Me.Text = "HitTest Demo"
        Me.Size = New Size(700, 250)

        ' Add MultiRow to Form
        Me.gcMultiRow1.Dock = DockStyle.Fill
        Me.Controls.Add(Me.gcMultiRow1)

        label.Height = 50
        label.Dock = DockStyle.Bottom
        label.BackColor = SystemColors.Info
        label.Text = "Right Click the ColumnHeader, the clicked cell will be auto fitted."
        Me.Controls.Add(label)

        Me.StartPosition = FormStartPosition.CenterScreen
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        gcMultiRow1.Template = Template.CreateGridTemplate(10)
        gcMultiRow1.RowCount = 5
    End Sub

    Private Sub gcMultiRow1_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs) Handles gcMultiRow1.MouseClick
        If e.Button = MouseButtons.Right Then
            Dim info As HitTestInfo = gcMultiRow1.HitTest(e.Location)
            If info.Type = HitTestType.ColumnHeader Then
                'If right click the ColumnHeader, the clicked cell will execute auto fit.
                Me.gcMultiRow1.ColumnHeaders(info.SectionIndex).Cells(info.CellIndex).PerformHorizontalAutoFit()
            End If
            label.Text = info.ToString()
        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
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.