HelpfulCollectionEditor.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright © 2005, Mathew Hall
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * - Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. *
  11. * - Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  16. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  18. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  19. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  21. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  22. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  23. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  24. * OF SUCH DAMAGE.
  25. */
  26. using System;
  27. using System.ComponentModel.Design;
  28. using System.Windows.Forms;
  29. namespace XPTable.Models.Design
  30. {
  31. /// <summary>
  32. /// A CollectionEditor that displays the help and command areas of its PropertyGrid
  33. /// </summary>
  34. public class HelpfulCollectionEditor : CollectionEditor
  35. {
  36. /// <summary>
  37. /// Initializes a new instance of the HelpfulCollectionEditor class using
  38. /// the specified collection type
  39. /// </summary>
  40. /// <param name="type">The type of the collection for this editor to edit</param>
  41. public HelpfulCollectionEditor(Type type) : base(type)
  42. {
  43. }
  44. /// <summary>
  45. /// Creates a new form to display and edit the current collection
  46. /// </summary>
  47. /// <returns>An instance of CollectionEditor.CollectionForm to provide as the
  48. /// user interface for editing the collection</returns>
  49. protected override CollectionEditor.CollectionForm CreateCollectionForm()
  50. {
  51. CollectionEditor.CollectionForm editor = base.CreateCollectionForm();
  52. foreach (Control control in editor.Controls)
  53. {
  54. //
  55. if (control is PropertyGrid)
  56. {
  57. PropertyGrid grid = (PropertyGrid) control;
  58. grid.HelpVisible = true;
  59. grid.CommandsVisibleIfAvailable = true;
  60. }
  61. }
  62. return editor;
  63. }
  64. }
  65. }