Name

DataGridColumnStyle

Synopsis

DataGridColumnStyle objects tell the data grid how to manage and display a particular column of data. First, you can specify the name of the data member to which this particular column is bound using the MappingName property. Note that you can only have one column per unique mapping. Then, specify the column HeaderText, the Alignment of the column text, and the Width of the column.

While various column style objects are provided by the system (such as DataGridBoolColumn and DataGridTextBoxColumn), you can derive your own to provide custom display and/or editing facilities.

You can override the Paint() method to provide custom rendering. Editing is initiated with the Edit() method, giving you the opportunity to show your own editing control, and Abort() is called if the grid wants you to attempt to abandon editing. If you need control over the row height, you can override GetMinimumHeight(), GetPreferredHeight(), and GetPreferredSize() to indicate to the system the requirements for this particular column.


public abstract class DataGridColumnStyle : System.ComponentModel.Component : IDataGridColumnStyleEditingNotificationService {

// Public Constructors

   public DataGridColumnStyle();

   public DataGridColumnStyle(System.ComponentModel.PropertyDescriptor prop);

// Public Instance Properties

   public virtual HorizontalAlignment Alignment{set; get; }

   public virtual DataGridTableStyle DataGridTableStyle{get; }

   public AccessibleObject HeaderAccessibleObject{get; ...

Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.