Skip to main content

Blog

C# - DataGridView - Drag and Drop Rows Reorder

The DataGridView controls doesn't have enabled drag and drop reordering rows by default. However, here is the code that you use in the future in your projects in order to implement rows reordering with drag and drop.

C# - DataGridView - SelectedIndexChanged Event

One of requests you could get to implement in an application is to know when a user selects an item in the Combobox editing control in a DataGridView.

SQL Server - Get Column Name and Type From Table

Microsoft SQL Server provides two methods for obtaining meta data: system stored procedures or information schema views.

Here are the SQL snippets for getting meta information about a database table in SQL Server. These queries could provide answer to the following requests:

C# - DataGridView - How to Hook Up Events on Editing Control

There are situations when you need to handle some events that are provided by a cell's editing cotrol in a DataGridView.

This can be done in the following way:

- Handle the DataGridView.EditingControlShowing event

- Access the DataGridViewEditingControlShowingEventArgs.Control property in order to get the editing control for the cell. If the event you are interested is not based on the Control class, maybe you need to perform casting the control to a specific control type.

C# - DataGridView - How to Disable Column Sort

By default, text box columns in the DataGridView control have automatic sorting, in contrary to other column types that don't use automatically sorting.

In order to change default sorting behavior of a column in the DataGridView control you can use the SortMode property.

This property determines a column's sorting behavior so you are able easily to change it.