指定した座標にある
GcMultiRowの部分に関する情報を格納します。このクラスは継承できません。
次のサンプルコードは、GcMultiRowのヒットテストの使用方法を示します。
ColumnHeaderSectionがマウスで右クリックされた場合、そのセルの幅が自動的に調整されます。
using System;
using System.Windows.Forms;
using System.Drawing;
namespace GrapeCity.Win.MultiRow.SampleCode
{
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();
}
}
[STAThreadAttribute()]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new HitTestDemo());
}
}
}
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports GrapeCity.Win.MultiRow
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
<STAThreadAttribute()> _
Public Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New HitTestDemo())
End Sub
End Class
System.Object
GrapeCity.Win.MultiRow.HitTestInfo