O'Reilly logo

.NET Windows Forms in a Nutshell by Matthew Adams, Ian Griffiths

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required