DataGrid.HitTestType Énumération
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Attention
DataGrid is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use DataGridView instead.
Spécifie la partie du contrôle DataGrid que l’utilisateur a cliqué.
Cette énumération prend en charge une combinaison au niveau du bit de ses valeurs membres.
public: enum class DataGrid::HitTestType
[System.Flags]
public enum DataGrid.HitTestType
[System.Flags]
[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 enum DataGrid.HitTestType
[<System.Flags>]
type DataGrid.HitTestType =
[<System.Flags>]
[<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 DataGrid.HitTestType =
Public Enum DataGrid.HitTestType
- Héritage
- Attributs
Champs
| Nom | Valeur | Description |
|---|---|---|
| None | 0 | Zone d’arrière-plan, visible lorsque le contrôle ne contient aucune table, quelques lignes ou lorsqu’une table fait défiler jusqu’à son bas. |
| Cell | 1 | Cellule du DataGrid contrôle. |
| ColumnHeader | 2 | En-tête de colonne dans le DataGrid contrôle. |
| RowHeader | 4 | En-tête de ligne dans le DataGrid contrôle. |
| ColumnResize | 8 | Bordure de colonne, qui correspond à la ligne entre les en-têtes de colonne. Il peut être déplacé pour redimensionner la largeur d’une colonne. |
| RowResize | 16 | Bordure de ligne, qui correspond à la ligne entre les en-têtes de ligne de grille. Il peut être déplacé pour redimensionner la hauteur d’une ligne. |
| Caption | 32 | Légende du DataGrid contrôle. |
| ParentRows | 64 | Section de ligne parente du DataGrid contrôle. La ligne parente affiche des informations à partir ou sur la table parente de la table enfant actuellement affichée, telle que le nom de la table parente, les noms de colonnes et les valeurs de l’enregistrement parent. |
Exemples
L’exemple suivant utilise la HitTest méthode dans un MouseDown événement pour retourner le DataGrid.HitTestInfo. La ligne, la colonne et la partie de la grille sont ensuite imprimées.
private:
void dataGrid1_MouseDown( Object^ /*sender*/,
System::Windows::Forms::MouseEventArgs^ e )
{
String^ newLine = "\n";
Console::WriteLine( newLine );
System::Windows::Forms::DataGrid::HitTestInfo^ myHitTest;
// Use the DataGrid control's HitTest method with the x and y properties.
myHitTest = dataGrid1->HitTest( e->X, e->Y );
Console::WriteLine( myHitTest );
Console::WriteLine( "Column {0}", myHitTest->Column );
Console::WriteLine( "Row {0}", myHitTest->Row );
Console::WriteLine( "Type {0}", myHitTest->Type );
Console::WriteLine( "ToString {0}", myHitTest );
Console::WriteLine( "Hit {0}", ReturnHitTest( myHitTest->Type ) );
}
String^ ReturnHitTest(
System::Windows::Forms::DataGrid::HitTestType hit )
{
// Use this function to return the part of the grid clicked.
switch ( hit )
{
case(System::Windows::Forms::DataGrid::HitTestType::Cell):
return "Cell";
case(System::Windows::Forms::DataGrid::HitTestType::Caption):
return "Caption";
case(System::Windows::Forms::DataGrid::HitTestType::ColumnHeader):
return "ColumnHeader";
case(System::Windows::Forms::DataGrid::HitTestType::ColumnResize):
return "Resize";
case(System::Windows::Forms::DataGrid::HitTestType::ParentRows):
return "ParentRows";
case(System::Windows::Forms::DataGrid::HitTestType::RowHeader):
return "RowHeader";
case(System::Windows::Forms::DataGrid::HitTestType::RowResize):
return "RowResize";
case(System::Windows::Forms::DataGrid::HitTestType::None):
return "None";
default:
return "Unknown";
}
}
private void dataGrid1_MouseDown
(object sender, System.Windows.Forms.MouseEventArgs e)
{
string newLine = "\n";
Console.WriteLine(newLine);
System.Windows.Forms.DataGrid.HitTestInfo myHitTest;
// Use the DataGrid control's HitTest method with the x and y properties.
myHitTest = dataGrid1.HitTest(e.X,e.Y);
Console.WriteLine(myHitTest);
Console.WriteLine("Column " + myHitTest.Column);
Console.WriteLine("Row " + myHitTest.Row);
Console.WriteLine("Type " + myHitTest.Type);
Console.WriteLine("ToString " + myHitTest.ToString());
Console.WriteLine("Hit " + ReturnHitTest(myHitTest.Type ));
}
private string ReturnHitTest(System.Windows.Forms.DataGrid.HitTestType hit ){
// Use this function to return the part of the grid clicked.
switch(hit) {
case(System.Windows.Forms.DataGrid.HitTestType.Cell):
return "Cell";
case(System.Windows.Forms.DataGrid.HitTestType.Caption):
return "Caption";
case(System.Windows.Forms.DataGrid.HitTestType.ColumnHeader):
return "ColumnHeader";
case(System.Windows.Forms.DataGrid.HitTestType.ColumnResize):
return "Resize";
case(System.Windows.Forms.DataGrid.HitTestType.ParentRows):
return "ParentRows";
case(System.Windows.Forms.DataGrid.HitTestType.RowHeader):
return "RowHeader";
case(System.Windows.Forms.DataGrid.HitTestType.RowResize):
return "RowResize";
case(System.Windows.Forms.DataGrid.HitTestType.None):
return "None";
default:return "Unknown";
}
}
Private Sub dataGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim newLine As String = ControlChars.Cr
Console.WriteLine(newLine)
Dim myHitTest As System.Windows.Forms.DataGrid.HitTestInfo
' Use the DataGrid control's HitTest method with the x and y properties.
myHitTest = dataGrid1.HitTest(e.X, e.Y)
Console.WriteLine(myHitTest)
Console.WriteLine(("Column " & myHitTest.Column))
Console.WriteLine(("Row " & myHitTest.Row))
Console.WriteLine(("Type " & myHitTest.Type))
Console.WriteLine(("ToString " & myHitTest.ToString()))
Console.WriteLine(("Hit " & ReturnHitTest(myHitTest.Type)))
End Sub
Private Function ReturnHitTest(hit As System.Windows.Forms.DataGrid.HitTestType) As String
' Use this function to return the part of the grid clicked.
Select Case hit
Case System.Windows.Forms.DataGrid.HitTestType.Cell
Return "Cell"
Case System.Windows.Forms.DataGrid.HitTestType.Caption
Return "Caption"
Case System.Windows.Forms.DataGrid.HitTestType.ColumnHeader
Return "ColumnHeader"
Case System.Windows.Forms.DataGrid.HitTestType.ColumnResize
Return "Resize"
Case System.Windows.Forms.DataGrid.HitTestType.ParentRows
Return "ParentRows"
Case System.Windows.Forms.DataGrid.HitTestType.RowHeader
Return "RowHeader"
Case System.Windows.Forms.DataGrid.HitTestType.RowResize
Return "RowResize"
Case System.Windows.Forms.DataGrid.HitTestType.None
Return "None"
Case Else
Return "Unknown"
End Select
End Function 'ReturnHitTest
Remarques
Utilisez les membres de cette énumération pour déterminer quelle partie de la grille a été cliquée. Propriété Type d’un DataGrid.HitTestInfo retour d’un DataGrid.HitTestType. Il DataGrid.HitTestInfo est créé en appelant la HitTest méthode d’un System.Windows.Forms.DataGrid contrôle.