DropDownColumn.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. //#########################################################################################
  2. //★★★★★★★ http://www.cnpopsoft.com [华普软件] ★★★★★★★
  3. //★★★★★★★ 华普软件 - VB & C#.NET 专业论文与源码荟萃! ★★★★★★★
  4. //#########################################################################################
  5. /*
  6. * Copyright ?2005, Mathew Hall
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modification,
  10. * are permitted provided that the following conditions are met:
  11. *
  12. * - Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. *
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  23. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  24. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  25. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  26. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  28. * OF SUCH DAMAGE.
  29. */
  30. using System;
  31. using System.ComponentModel;
  32. using System.Drawing;
  33. using XPTable.Editors;
  34. using XPTable.Events;
  35. using XPTable.Renderers;
  36. namespace XPTable.Models
  37. {
  38. /// <summary>
  39. /// Represents a Column whose Cells are displayed with a drop down
  40. /// button for editing
  41. /// </summary>
  42. [DesignTimeVisible(false),
  43. ToolboxItem(false)]
  44. public abstract class DropDownColumn : Column
  45. {
  46. #region Class Data
  47. /// <summary>
  48. /// Specifies whether the Cells should draw a drop down button
  49. /// </summary>
  50. private bool showButton;
  51. #endregion
  52. #region Constructor
  53. /// <summary>
  54. /// Creates a new DropDownColumn with default values
  55. /// </summary>
  56. public DropDownColumn() : base()
  57. {
  58. this.Init();
  59. }
  60. /// <summary>
  61. /// Creates a new DropDownColumn with the specified header text
  62. /// </summary>
  63. /// <param name="text">The text displayed in the column's header</param>
  64. public DropDownColumn(string text) : base(text)
  65. {
  66. this.Init();
  67. }
  68. /// <summary>
  69. /// Creates a new DropDownColumn with the specified header text and width
  70. /// </summary>
  71. /// <param name="text">The text displayed in the column's header</param>
  72. /// <param name="width">The column's width</param>
  73. public DropDownColumn(string text, int width) : base(text, width)
  74. {
  75. this.Init();
  76. }
  77. /// <summary>
  78. /// Creates a new DropDownColumn with the specified header text, width and visibility
  79. /// </summary>
  80. /// <param name="text">The text displayed in the column's header</param>
  81. /// <param name="width">The column's width</param>
  82. /// <param name="visible">Specifies whether the column is visible</param>
  83. public DropDownColumn(string text, int width, bool visible) : base(text, width, visible)
  84. {
  85. this.Init();
  86. }
  87. /// <summary>
  88. /// Creates a new DropDownColumn with the specified header text and image
  89. /// </summary>
  90. /// <param name="text">The text displayed in the column's header</param>
  91. /// <param name="image">The image displayed on the column's header</param>
  92. public DropDownColumn(string text, Image image) : base(text, image)
  93. {
  94. this.Init();
  95. }
  96. /// <summary>
  97. /// Creates a new DropDownColumn with the specified header text, image and width
  98. /// </summary>
  99. /// <param name="text">The text displayed in the column's header</param>
  100. /// <param name="image">The image displayed on the column's header</param>
  101. /// <param name="width">The column's width</param>
  102. public DropDownColumn(string text, Image image, int width) : base(text, image, width)
  103. {
  104. this.Init();
  105. }
  106. /// <summary>
  107. /// Creates a new DropDownColumn with the specified header text, image, width and visibility
  108. /// </summary>
  109. /// <param name="text">The text displayed in the column's header</param>
  110. /// <param name="image">The image displayed on the column's header</param>
  111. /// <param name="width">The column's width</param>
  112. /// <param name="visible">Specifies whether the column is visible</param>
  113. public DropDownColumn(string text, Image image, int width, bool visible) : base(text, image, width, visible)
  114. {
  115. this.Init();
  116. }
  117. /// <summary>
  118. /// Initializes the DropDownColumn with default values
  119. /// </summary>
  120. private void Init()
  121. {
  122. this.showButton = true;
  123. }
  124. #endregion
  125. #region Properties
  126. /// <summary>
  127. /// Gets or sets whether the Column's Cells should draw a drop down button
  128. /// </summary>
  129. [Category("Appearance"),
  130. DefaultValue(true),
  131. Description("Determines whether the Column's Cells should draw a drop down button")]
  132. public bool ShowDropDownButton
  133. {
  134. get
  135. {
  136. return this.showButton;
  137. }
  138. set
  139. {
  140. if(this.showButton != value)
  141. {
  142. this.showButton = value;
  143. this.OnPropertyChanged(new ColumnEventArgs(this, ColumnEventType.RendererChanged, null));
  144. }
  145. }
  146. }
  147. #endregion
  148. }
  149. }