PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/Visual Studio 2008/CSWinFormDataGridView/MultipleLayeredColumnHeader/ReadMe.txt

#
Plain Text | 65 lines | 42 code | 23 blank | 0 comment | 0 complexity | d46903d08538f44dcee309ae212cdddd MD5 | raw file
 1================================================================================
 2       WINDOWS FORMS APPLICATION : CSWinFormDataGridView Project Overview
 3       
 4                   MultipleLayeredColumnHeader Sample
 5                        
 6===============================================================================
 7
 8/////////////////////////////////////////////////////////////////////////////
 9Use:
10
11This sample demonstrates how to display multiple layer column headers on the 
12DataGridView contorl.
13
14
15-----------------------------------------------------------------
16      |   January      |   February      |     March      |
17      |  Win  | Loss   |  Win   | Loss   |  Win   | Loss  |
18-----------------------------------------------------------------
19Team1 |       |        |        |        |        |       |
20-----------------------------------------------------------------
21Team2 |       |        |        |        |        |       |
22-----------------------------------------------------------------
23TeamN |       |        |        |        |        |       |
24-----------------------------------------------------------------
25
26
27/////////////////////////////////////////////////////////////////////////////
28Code Logic:
29
301.  Enable resizing on the column headers by setting the 
31    ColumnHeadersHeightSizeMode property as follows:
32
33    this.dataGridView1.ColumnHeadersHeightSizeMode =
34         DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
35
362.  Adjust the height for the column headers to make it wide enough for two 
37    layers;
38
39    this.dataGridView1.ColumnHeadersHeight =
40         this.dataGridView1.ColumnHeadersHeight * 2;
41                        
42                        
433.  Adjust the text alignment on the column headers to make the text display 
44    at the center of the bottom;
45    
46    this.dataGridView1.ColumnHeadersDefaultCellStyle.Alignment =
47         DataGridViewContentAlignment.BottomCenter;
48    
494.  Handle the DataGridView.CellPainting event to draw text for each header 
50    cell;
51
525.  Handle the DataGridView.Paint event to draw "merged" header cells;
53
54
55/////////////////////////////////////////////////////////////////////////////
56References:
57
581. DataGridView Class
59   http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx
60   
612. Windows Forms FAQs
62   http://windowsclient.net/blogs/faqs/archive/tags/Custom+Designers/default.aspx
63
64
65/////////////////////////////////////////////////////////////////////////////