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

DataGridTableStyle

Synopsis

This class is used to customize the binding and appearance of a DataGrid. While the default implementation will automatically create appropriate tables and columns for your data source, you can take more control by adding this information by hand.

You do this through the DataGrid.TableStyles property. For each table in your data source that you want to display in the grid, you create a DataGridTableStyle object. First, you can set the data table to which this object is bound through the MappingName property. You can then independently control the colors, grid lines, widths, and heights for which you set defaults in the parent grid, before adding DataGridColumnStyle objects to the GridColumnStyles collection that represent each column in that table.


public class DataGridTableStyle : System.ComponentModel.Component : IDataGridEditingService {

// Public Constructors

   public DataGridTableStyle();

   public DataGridTableStyle(bool isDefaultTableStyle);

   public DataGridTableStyle(CurrencyManager listManager);

// Public Static Fields

   public static DataGridTableStyle DefaultTableStyle;  // =System.Windows.Forms.DataGridTableStyle

                  // Public Instance Properties

   public bool AllowSorting{set; get; }

   public Color AlternatingBackColor{set; get; }

   public Color BackColor{set; get; }

   public bool ColumnHeadersVisible{set; get; }

   public virtual DataGrid DataGrid{set; get; }

   public Color ForeColor{set; get; }

   public virtual GridColumnStylesCollection GridColumnStyles{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