Gridview control with all events
Loading
Gridview control with all events
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Cr BhargaviPosted Aug 3, 2023, 5:20 AM
The `GridView` control in WinForms provides a tabular view of data, allowing users to display, edit, and interact with data in a grid format. Below is an overview of some of the common events available in the `GridView` control along with their purposes:
1. `CellClick`: This event occurs when the user clicks on a cell in the `GridView`. It is commonly used to handle cell-specific actions or to capture the selected cell's value.
2. `CellDoubleClick`: This event is triggered when the user double-clicks on a cell. It allows you to implement special behavior when the user rapidly interacts with a cell.
3. `RowEnter`: This event is raised when the user navigates to a new row in the `GridView`. It can be used to perform actions when a specific row is selected.
4. `RowLeave`: This event is raised when the focus leaves a row in the `GridView`. It can be useful for performing actions when the user moves to a different row.
5. `RowHeaderMouseClick`: This event occurs when the user clicks on the row header, the area on the left side of the `GridView`. It can be used to perform actions based on row selection from the header.
6. `RowHeaderMouseDoubleClick`: This event is triggered when the user double-clicks on the row header. It allows you to implement special behavior when the user rapidly interacts with the row header.
7. `CellValueChanged`: This event is raised when the value of a cell is changed by the user. It can be used to handle data changes in the `GridView`.
8. `CellFormatting`: This event allows you to customize the appearance of cells based on certain conditions. You can change the cell's font, color, or other visual attributes dynamically.
9. `CellValidating`: This event occurs when a cell's value is being validated, typically when the user moves to another cell or tries to commit the edit. It is commonly used to perform data validation before updating the underlying data source.
10. `KeyDown`: This event is triggered when a key is pressed while the `GridView` has focus. It can be used to implement keyboard shortcuts or handle specific key actions.
11. `MouseHover`: This event occurs when the mouse pointer hovers over a cell in the `GridView`. It can be used to provide tooltips or other information related to the cell.
These are just some of the common events available in the `GridView` control. Depending on your specific use case, you may use additional events and customize their behavior to meet your application's requirements. Handling these events effectively can enhance the interactivity and functionality of your `GridView` control in the WinForms application.
Tahir AnsariPosted Aug 2, 2023, 10:43 AM
Hi Atish try below sample code
Step 1: Set up the GridView control in your web form:
Step 2: Bind data to the GridView:
Mohammad HussainPosted Aug 2, 2023, 3:36 AM