PageRenderTime 28ms CodeModel.GetById 1ms RepoModel.GetById 0ms 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. MultipleLayeredColumnHeader Sample
  4. ===============================================================================
  5. /////////////////////////////////////////////////////////////////////////////
  6. Use:
  7. This sample demonstrates how to display multiple layer column headers on the
  8. DataGridView contorl.
  9. -----------------------------------------------------------------
  10. | January | February | March |
  11. | Win | Loss | Win | Loss | Win | Loss |
  12. -----------------------------------------------------------------
  13. Team1 | | | | | | |
  14. -----------------------------------------------------------------
  15. Team2 | | | | | | |
  16. -----------------------------------------------------------------
  17. TeamN | | | | | | |
  18. -----------------------------------------------------------------
  19. /////////////////////////////////////////////////////////////////////////////
  20. Code Logic:
  21. 1. Enable resizing on the column headers by setting the
  22. ColumnHeadersHeightSizeMode property as follows:
  23. this.dataGridView1.ColumnHeadersHeightSizeMode =
  24. DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
  25. 2. Adjust the height for the column headers to make it wide enough for two
  26. layers;
  27. this.dataGridView1.ColumnHeadersHeight =
  28. this.dataGridView1.ColumnHeadersHeight * 2;
  29. 3. Adjust the text alignment on the column headers to make the text display
  30. at the center of the bottom;
  31. this.dataGridView1.ColumnHeadersDefaultCellStyle.Alignment =
  32. DataGridViewContentAlignment.BottomCenter;
  33. 4. Handle the DataGridView.CellPainting event to draw text for each header
  34. cell;
  35. 5. Handle the DataGridView.Paint event to draw "merged" header cells;
  36. /////////////////////////////////////////////////////////////////////////////
  37. References:
  38. 1. DataGridView Class
  39. http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx
  40. 2. Windows Forms FAQs
  41. http://windowsclient.net/blogs/faqs/archive/tags/Custom+Designers/default.aspx
  42. /////////////////////////////////////////////////////////////////////////////