JayBeeOH

DataGridView Properties Settings Notes

Jun 29th, 2015
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. '------------------------------------------------------------------------------------------
  2. ' Notice of My Copyright and Intellectual Property Rights
  3. '
  4. ' Any intellectual property contained within the program by Joseph L. Bolen remains the
  5. ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
  6. ' publish or provide such intellectual property to any other person or entity for any
  7. ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
  8. '
  9. ' Copyright © 2015. All rights reserved.
  10. ' All trademarks remain the property of their respective owners.
  11. '-------------------------------------------------------------------------------------------
  12. DataGridiView Properties Settings Notes:
  13. This documentation is at: http://pastebin.com/nCZDAmRG
  14.  
  15. .AllowUserToOrderColumns = True
  16.  
  17. .AlternatingRowsDefaultCellStyle.BackColor = Color.WhiteSmoke
  18.  
  19. .Anchor = Top, Bottom, Left, Right (or Dock = Fill)
  20.  
  21. .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells (or DisplayedCellsExceptHeader)
  22.  
  23. .BorderStyle = BorderStyle.Fixed3D
  24.  
  25. .ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText
  26. (Default. However, if SelectionMode is not "RowHeaderSelect" or "ColumnHeaderSelect", you may wish to
  27. change this to "EnableAlwaysIncludeHeaderText".)
  28.  
  29. .ColumnHeadersDefaultCellStyle.Font = New Font(.Font, FontStyle.Bold) NOTE: Only works in code.
  30.  
  31. .ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing (Default is AutoSize.)
  32.  
  33. .DataSource = (Set to your BindingSource)
  34.  
  35. .MultiSelect = False (default True)
  36.  
  37. .RowHeadersVisible = True (If ReadOnly on DataGridView, you may wish to use False.
  38.  
  39. SelectionMode = RowHeaderSelect (default) or FullRowSelect
  40.  
  41. Individual Cells of DataGridView:
  42. 1) If special processing is to be done on the cell, then rename the column's Name property to a more descriptive name, e.g., "LastNameCol".
  43.  
  44. 2) If Numeric or DateTime, then format and align ...
  45. .Columns("BirthDateCol").DefaultCellStyle.Format = "d"
  46. .Columns("BirthDateCol").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  47. .Columns("HireDateCol").DefaultCellStyle.Format = "yyyy-MM-dd"
  48. .Columns("PriceCol").DefaultCellStyle.Format = "C"
  49. .Columns("PriceCol").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  50. Use Numeric and DateTime Format Specifiers - "d, t, s, u, C, N, etc."
  51.  
  52. Last Cell of DataGridView:
  53. AutoSizeMode = Fill (All other cells NotSet)
  54. MinimumWidth = 100 (?)
  55.  
  56. Special Note:
  57. If a column cell is Frozen, all columns to the left are Frozen.
Advertisement
Add Comment
Please, Sign In to add comment