Skip to main content

CODING

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.

C# - DataGridView - How to Hide a Column

There are situation when you would like to show only some of the columns that are available in a DataGridView on your form. E.g. a DataGridView could display contact information to system administrators, but for every other user else these information would be hidden.