ComboBox.cs
上传用户:husern
上传日期:2022-03-24
资源大小:534k
文件大小:3k
源码类别:

编辑器/阅读器

开发平台:

C#

  1. // -- FILE ------------------------------------------------------------------
  2. // name       : ComboBox.cs
  3. // project    : Itenso Web User Forms
  4. // created    : Jani Giannoudis - 2008.10.30
  5. // language   : c#
  6. // environment: .NET 2.0
  7. // copyright  : (c) 2008 by Itenso GmbH, Switzerland
  8. // --------------------------------------------------------------------------
  9. using System;
  10. using System.Web.UI.WebControls;
  11. using Itenso.WebUserForms.Controls;
  12. namespace Itenso.WebUserForms.RuntimeControls
  13. {
  14. #if TP_COMBO_FIELDS
  15. // ------------------------------------------------------------------------
  16. public class ComboBox : System.Web.UI.WebControls.DropDownList, IListField
  17. {
  18. // ----------------------------------------------------------------------
  19. public ComboBox( Itenso.WebUserForms.Controls.ComboBox comboBox )
  20. {
  21. if ( comboBox == null )
  22. {
  23. throw new ArgumentNullException( "comboBox" );
  24. }
  25. // form values
  26. if ( !string.IsNullOrEmpty( comboBox.FieldName ) )
  27. {
  28. this.FieldName = comboBox.FieldName;
  29. }
  30. if ( !string.IsNullOrEmpty( comboBox.FieldValue ) )
  31. {
  32. this.FieldValue = comboBox.FieldValue;
  33. }
  34. // control values
  35. this.ID = comboBox.ID;
  36. this.Width = comboBox.Width;
  37. this.CssClass = comboBox.CssClass;
  38. foreach ( ListItem listItem in comboBox.Items )
  39. {
  40. Items.Add( new ListItem( listItem.Text, listItem.Value ) );
  41. }
  42. this.SelectedIndex = comboBox.SelectedIndex;
  43. this.Text = comboBox.Text;
  44. } // ComboBox
  45. // ----------------------------------------------------------------------
  46. public string FieldName
  47. {
  48. get { return this.fieldName; }
  49. set { this.fieldName = value; }
  50. } // FieldName
  51. // ----------------------------------------------------------------------
  52. public string FieldValue
  53. {
  54. get { return SelectedValue; }
  55. set
  56. {
  57. ListItem listItem = Items.FindByValue( value );
  58. if ( listItem != null )
  59. {
  60. SelectedIndex = Items.IndexOf( listItem );
  61. }
  62. }
  63. } // FieldValue
  64. // ----------------------------------------------------------------------
  65. bool IUserFormField.AllowEdit
  66. {
  67. get { return base.Enabled; }
  68. set { base.Enabled= value; }
  69. } // AllowEdit
  70. // ----------------------------------------------------------------------
  71. public override string ToString()
  72. {
  73. return FormFieldTool.GetFieldDescription( this );
  74. } // ToString
  75. // ----------------------------------------------------------------------
  76. // members
  77. private string fieldName;
  78. } // class ComboBox
  79. #endif // TP_COMBO_FIELDS
  80. } // namespace Itenso.WebUserForms.RuntimeControls
  81. // -- EOF -------------------------------------------------------------------