DataGrid.CurrentCell 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定由那個儲存格取得焦點 (Focus)。 無法在設計階段使用。
public:
property System::Windows::Forms::DataGridCell CurrentCell { System::Windows::Forms::DataGridCell get(); void set(System::Windows::Forms::DataGridCell value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.DataGridCell CurrentCell { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.CurrentCell : System.Windows.Forms.DataGridCell with get, set
Public Property CurrentCell As DataGridCell
屬性值
具有焦點的 DataGridCell。
- 屬性
範例
下列程式碼範例示範如何設定和取得目前的儲存格。
private:
void SetCellWithFocus( DataGrid^ myGrid )
{
// Set the current cell to cell1, row 1.
myGrid->CurrentCell = DataGridCell( 1, 1 );
}
void dataGrid1_GotFocus( Object^ /*sender*/, EventArgs^ /*e*/ )
{
Console::WriteLine( "{0} {1}", dataGrid1->CurrentCell.ColumnNumber,
dataGrid1->CurrentCell.RowNumber );
}
private void SetCellWithFocus(DataGrid myGrid)
{
// Set the current cell to cell1, row 1.
myGrid.CurrentCell = new DataGridCell(1,1);
}
private void dataGrid1_GotFocus(object sender, EventArgs e)
{
Console.WriteLine(dataGrid1.CurrentCell.ColumnNumber +
" " + dataGrid1.CurrentCell.RowNumber);
}
Private Sub SetCellWithFocus(ByVal myGrid As DataGrid)
' Set the current cell to cell 1, row 1.
myGrid.CurrentCell = New DataGridCell(1,1)
End Sub
Private Sub DataGrid1_GotFocus(ByVal Sender As Object, ByVal e As EventArgs)
Console.WriteLine(DataGrid1.CurrentCell.ColumnNumber & " " & _
DataGrid1.CurrentCell.RowNumber)
End Sub
備註
CurrentCell設定 屬性會導致格線捲動,如果儲存格尚未顯示,則會顯示該儲存格。