Freigeben über


DataGrid.CurrentCell-Eigenschaft

Ruft ab oder legt fest, welche Zelle den Fokus besitzt. Zur Entwurfszeit nicht verfügbar.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Property CurrentCell As DataGridCell
'Usage
Dim instance As DataGrid
Dim value As DataGridCell

value = instance.CurrentCell

instance.CurrentCell = value
public DataGridCell CurrentCell { get; set; }
public:
property DataGridCell CurrentCell {
    DataGridCell get ();
    void set (DataGridCell value);
}
/** @property */
public DataGridCell get_CurrentCell ()

/** @property */
public void set_CurrentCell (DataGridCell value)
public function get CurrentCell () : DataGridCell

public function set CurrentCell (value : DataGridCell)

Eigenschaftenwert

Die DataGridCell, die den Fokus besitzt.

Hinweise

Durch Festlegen der CurrentCell-Eigenschaft wird ein Bildlauf im Datenblatt durchgeführt, um die Zelle anzuzeigen, sofern diese nicht bereits angezeigt wird.

Beispiel

Im folgenden Codebeispiel wird das Festlegen und Abrufen der aktuellen Zelle veranschaulicht.

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
    
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:
   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.set_CurrentCell(new DataGridCell(1, 1));
} //SetCellWithFocus

private void dataGrid1_GotFocus(Object sender, EventArgs e)
{
    Console.WriteLine(dataGrid1.get_CurrentCell().get_ColumnNumber()
        + " " + dataGrid1.get_CurrentCell().get_RowNumber());
} //dataGrid1_GotFocus

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

DataGrid-Klasse
DataGrid-Member
System.Windows.Forms-Namespace
DataGridCell
FirstVisibleColumn