ListBoxControl.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Windows.Forms;
  5. namespace FastReport.Dialog
  6. {
  7. /// <summary>
  8. /// Represents a Windows control to display a list of items.
  9. /// Wraps the <see cref="System.Windows.Forms.ListBox"/> control.
  10. /// </summary>
  11. public class ListBoxControl : ListBoxBaseControl
  12. {
  13. private ListBox listBox;
  14. #region Properties
  15. /// <summary>
  16. /// Gets an internal <b>ListBox</b>.
  17. /// </summary>
  18. [Browsable(false)]
  19. public ListBox ListBox
  20. {
  21. get { return listBox; }
  22. }
  23. #endregion
  24. #region Protected Methods
  25. /// <inheritdoc/>
  26. protected override object GetValue()
  27. {
  28. List<string> list = new List<string>();
  29. foreach (object item in SelectedItems)
  30. {
  31. list.Add((string)item);
  32. }
  33. return list.ToArray();
  34. }
  35. #endregion
  36. #region Public Methods
  37. /// <inheritdoc/>
  38. public override void OnSelectedIndexChanged(EventArgs e)
  39. {
  40. OnFilterChanged();
  41. base.OnSelectedIndexChanged(e);
  42. }
  43. #endregion
  44. /// <summary>
  45. /// Initializes a new instance of the <b>ListBoxControl</b> class with default settings.
  46. /// </summary>
  47. public ListBoxControl()
  48. {
  49. listBox = new ListBox();
  50. Control = listBox;
  51. ListBox.IntegralHeight = false;
  52. BindableProperty = this.GetType().GetProperty("SelectedItem");
  53. }
  54. }
  55. }