ListViewEx.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using System.IO;
  6. using System.Drawing;
  7. using System.Drawing.Drawing2D;
  8. using System.ComponentModel;
  9. using System.Data;
  10. namespace LYFZ.ComponentLibrary
  11. {
  12. public class ListViewEx : System.Windows.Forms.ListView
  13. {
  14. public ListViewEx()
  15. {
  16. }
  17. private bool _isDefaultShowGroups;
  18. /// <summary>
  19. /// 默认是否显示分组
  20. /// </summary>
  21. public bool IsDefaultShowGroups
  22. {
  23. get
  24. { return _isDefaultShowGroups; }
  25. set
  26. { _isDefaultShowGroups = value; }
  27. }
  28. /// <summary>
  29. /// 默认显示分组
  30. /// </summary>
  31. public bool DefaultShowGroups = true;
  32. /// <summary>
  33. /// 默认不显示分组
  34. /// </summary>
  35. public bool DefaultNotShowGroups = false;
  36. const int WM_HSCROLL = 0x0114;
  37. const int WM_VSCROLL = 0x0115;
  38. /// <summary>
  39. /// 重写滚动条滚动事件
  40. /// </summary>
  41. /// <param name="m"></param>
  42. protected override void WndProc(ref Message m)
  43. {
  44. if (m.Msg == WM_HSCROLL)
  45. { OnHScroll(this, new EventArgs()); }
  46. else if (m.Msg == WM_VSCROLL)
  47. { OnVScroll(this, new EventArgs()); }
  48. base.WndProc(ref m);
  49. }
  50. /// <summary>
  51. /// 滚动条滚动事件
  52. /// </summary>
  53. public event EventHandler Scroll;
  54. /// <summary>
  55. /// 重写滚动条滚动事件
  56. /// </summary>
  57. /// <param name="sender"></param>
  58. /// <param name="e"></param>
  59. virtual protected void OnHScroll(object sender, EventArgs e)
  60. {
  61. if (Scroll != null)
  62. Scroll(this, e);
  63. }
  64. /// <summary>
  65. /// 重写滚动条滚动事件
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. virtual protected void OnVScroll(object sender, EventArgs e)
  70. {
  71. if (Scroll != null)
  72. Scroll(this, e);
  73. }
  74. }
  75. }