DataGridCell Struct-datatyp
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Varning
DataGrid is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use DataGridView instead.
Identifierar en cell i rutnätet.
public value class DataGridCell
public struct DataGridCell
[System.ComponentModel.Browsable(false)]
[System.Obsolete("`DataGrid` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `DataGridView` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
public struct DataGridCell
type DataGridCell = struct
[<System.ComponentModel.Browsable(false)>]
[<System.Obsolete("`DataGrid` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `DataGridView` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
type DataGridCell = struct
Public Structure DataGridCell
- Arv
- Attribut
Exempel
I följande exempel tilldelas DataGridCell till CurrentCell för en System.Windows.Forms.DataGrid och returnerar kolumn- och radnumret för den markerade cellen. Värdet som lagras i DataTable skrivs också ut med hjälp av DataGridCell objektets RowNumber och ColumnNumber.
void PrintCellRowAndCol()
{
DataGridCell^ myCell;
myCell = DataGrid1->CurrentCell;
Console::WriteLine( myCell->RowNumber );
Console::WriteLine( myCell->ColumnNumber );
// Prints the value of the cell through the DataTable.
DataTable^ myTable;
// Assumes the DataGrid is bound to a DataTable.
myTable = dynamic_cast<DataTable^>(DataGrid1->DataSource);
Console::WriteLine( myTable->Rows[ myCell->RowNumber ][ myCell->ColumnNumber ] );
}
private void PrintCellRowAndCol()
{
DataGridCell myCell;
myCell = DataGrid1.CurrentCell;
Console.WriteLine(myCell.RowNumber);
Console.WriteLine(myCell.ColumnNumber);
// Prints the value of the cell through the DataTable.
DataTable myTable;
// Assumes the DataGrid is bound to a DataTable.
myTable = (DataTable) DataGrid1.DataSource;
Console.WriteLine(myTable.Rows[myCell.RowNumber]
[myCell.ColumnNumber]);
}
Private Sub PrintCellRowAndCol()
Dim myCell As DataGridCell
myCell = DataGrid1.CurrentCell
Console.WriteLine(myCell.RowNumber)
Console.WriteLine(myCell.ColumnNumber)
' Prints the value of the cell through the DataTable.
Dim myTable As DataTable
' Assumes the DataGrid is bound to a DataTable.
myTable = CType(DataGrid1.DataSource, DataTable)
Console.WriteLine(myTable.Rows(myCell.RowNumber)(myCell.ColumnNumber))
End Sub
Kommentarer
DataGridCell kan användas tillsammans med System.Windows.Forms.DataGrid-kontrollens egenskap CurrentCell för att hämta eller ange värdet för valfri cell. Om System.Windows.Forms.DataGrid-kontrollens egenskap CurrentCell till en DataGridCell flyttas fokus till cellen som anges av DataGridCell.
Konstruktorer
| Name | Description |
|---|---|
| DataGridCell(Int32, Int32) |
Föråldrad.
Initierar en ny instans av DataGridCell klassen. |
Egenskaper
| Name | Description |
|---|---|
| ColumnNumber |
Föråldrad.
Hämtar eller anger antalet kolumner i DataGrid kontrollen. |
| RowNumber |
Föråldrad.
Hämtar eller anger antalet rader i DataGrid kontrollen. |
Metoder
| Name | Description |
|---|---|
| Equals(Object) |
Föråldrad.
Hämtar ett värde som anger om DataGridCell är identiskt med en andra DataGridCell. |
| GetHashCode() |
Föråldrad.
Hämtar ett hash-värde som kan läggas till i en Hashtable. |
| ToString() |
Föråldrad.
Hämtar cellens radnummer och kolumnnummer. |