Custom Header Cells : DataGridView « GUI Windows Forms « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » GUI Windows Forms » DataGridView 
23.83.4.Custom Header Cells
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


   class Form1 : Form
   {
      public Form1()
      {
         InitializeComponent();
      }

      private void OnFormLoad(object sender, EventArgs e)
      {
         m_Grid.ColumnCount = 5;
         m_Grid.Rows.Add(5);
      }

      private void OnCellPainting(object sender, DataGridViewCellPaintingEventArgs e)
      {
         if (e.RowIndex == -1
         {
               e.Graphics.FillRectangle(Brushes.Aqua, e.CellBounds)
               e.Handled = true;
         }
         if (e.ColumnIndex == -1)
         {
         }
      }
      private void InitializeComponent()
      {
         this.m_Grid = new System.Windows.Forms.DataGridView();
         ((System.ComponentModel.ISupportInitialize)(this.m_Grid)).BeginInit();
         this.SuspendLayout();
         // 
         this.m_Grid.Dock = System.Windows.Forms.DockStyle.Fill;
         this.m_Grid.Location = new System.Drawing.Point(00);
         this.m_Grid.Name = "m_Grid";
         this.m_Grid.Size = new System.Drawing.Size(642347);
         this.m_Grid.TabIndex = 0;
         this.m_Grid.Text = "dataGridView1";
         this.m_Grid.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.OnCellPainting);
         // 
         // Form1
         // 
         this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
         this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
         this.ClientSize = new System.Drawing.Size(642347);
         this.Controls.Add(this.m_Grid);
         this.Name = "Form1";
         this.Text = "Form1";
         this.Load += new System.EventHandler(this.OnFormLoad);
         ((System.ComponentModel.ISupportInitialize)(this.m_Grid)).EndInit();
         this.ResumeLayout(false);

      }


      private System.Windows.Forms.DataGridView m_Grid;

      [STAThread]
      static void Main()
      {
         Application.EnableVisualStyles();
         Application.Run(new Form1());
      }
   }
23.83.DataGridView
23.83.1.Simple DataGridView
23.83.2.Programmatic Grid
23.83.3.Calculation with DataGridView
23.83.4.Custom Header Cells
23.83.5.Fill Columns
23.83.6.Virtual Data
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.