creer une fonction qui renvoie la position d'une cellule en c# d'un TableLayoutPanel qui…
- User
creer une fonction qui renvoie la position d'une cellule en c# d'un TableLayoutPanel qui s'appele tlpPanel
- Assistant
Vous pouvez créer une fonction qui parcourt les contrôles d'un
TableLayoutPanelet renvoie la position d'un contrôle spécifique sous forme deTableLayoutPanelCellPosition. Voici un exemple de fonction en C# :using System.Windows.Forms; public TableLayoutPanelCellPosition GetCellPosition(TableLayoutPanel tlpPanel, Control targetControl) { for (int row = 0; row < tlpPanel.RowCount; row++) { for (int column = 0; column < tlpPanel.ColumnCount; column++) { Control control = tlpPanel.GetControlFromPosition(column, row); if (control == targetControl) { return new TableLayoutPanelCellPosition(column, row); } } } // Si le contrôle n'est pas trouvé, renvoie une position invalide (-1, -1) return new TableLayoutPanelCellPosition(-1, -1); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.