DataGrid.CurrentCell Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets which cell has the focus. Not available at design time.
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
Property Value
The DataGridCell with the focus.
- Attributes
Examples
The following code example shows how to set and get the current cell.
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
Remarks
Setting the CurrentCell property will cause the grid to scroll and show the cell if it is not already visible.
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET