DataGrid.CurrentCell 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置具有焦点的单元格。 设计时不可用。
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 将导致网格滚动并显示单元格(如果尚未显示)。