DataGrid.HitTestInfo.Column 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得使用者點擊的欄位號碼。
public:
property int Column { int get(); };
public int Column { get; }
member this.Column : int
Public ReadOnly Property Column As Integer
屬性值
柱號。
範例
以下範例透過呼叫 HitTest 方法,從 MouseDown 控制項的 System.Windows.Forms.DataGrid 事件中,列印出被點擊列與列的號碼。 這會傳回一個DataGrid.HitTestInfo 物件。
private:
void dataGrid1_MouseDown( Object^ /*sender*/,
System::Windows::Forms::MouseEventArgs^ e )
{
String^ newLine = "\n";
Console::WriteLine( newLine );
System::Windows::Forms::DataGrid::HitTestInfo^ myHitTest;
/* Use the DataGrid control's HitTest method with
the x and y properties. */
myHitTest = dataGrid1->HitTest( e->X, e->Y );
Console::WriteLine( "Column {0}", myHitTest->Column );
Console::WriteLine( "Row {0}", myHitTest->Row );
}
private void dataGrid1_MouseDown
(object sender, System.Windows.Forms.MouseEventArgs e)
{
string newLine = "\n";
Console.WriteLine(newLine);
System.Windows.Forms.DataGrid.HitTestInfo myHitTest;
/* Use the DataGrid control's HitTest method with
the x and y properties. */
myHitTest = dataGrid1.HitTest(e.X,e.Y);
Console.WriteLine("Column " + myHitTest.Column);
Console.WriteLine("Row " + myHitTest.Row);
}
Private Sub dataGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim newLine As String = ControlChars.Cr
Console.WriteLine(newLine)
Dim myHitTest As System.Windows.Forms.DataGrid.HitTestInfo
' Use the DataGrid control's HitTest method with
' the x and y properties.
myHitTest = dataGrid1.HitTest(e.X, e.Y)
Console.WriteLine(("Column " & myHitTest.Column))
Console.WriteLine(("Row " & myHitTest.Row))
End Sub
備註
若座標非儲存格,屬性回傳為 -1。