Skip to content

DataGridViewColumn

Radu Martin edited this page Apr 14, 2017 · 9 revisions

These extenders provide a lot of style settings. The main static method is:

SetStyles(int Width, 
          DataGridViewContentAlignment Alignment,
          string Format)

Width - width of the column,
Alignment - indicating the position of the cell content,
Format - format string applied to the textual content.

In addition, there are static methods for configuring different styles:

// The column width adjusts to fill the entire free space
SetAutoSizeFillStyle()

// The column width adjusts to fit the contents of all cells in the column
SetAutoSizeAllCellsStyle()

// format string applied to the textual content is "N0"
SetNumberStyle()

// format string applied to the textual content is "N"
SetDecimalStyle()

// format string applied to the textual content is "C"
SetMoneyStyle()

// format string applied to the textual content is "P"
SetPercentStyle()

// format string applied to the textual content is "d"
SetDateStyle()

// format string applied to the textual content is "g"
SetDateTimeStyle()

// format string applied to the textual content is "G"
SetDateTimeWithSecondsStyle()

Execution can be combined, because these methods return the initial column:

column.SetDateTimeStyle().SetAutoSizeFillStyle(100);