BandComboBox.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Windows.Forms;
  2. using System.Drawing;
  3. using FastReport.Utils;
  4. using System.ComponentModel;
  5. namespace FastReport.Controls
  6. {
  7. #if !DEBUG
  8. [DesignTimeVisible(false)]
  9. #endif
  10. internal class BandComboBox : ComboBox
  11. {
  12. protected override void OnDrawItem(DrawItemEventArgs e)
  13. {
  14. e.DrawBackground();
  15. if (e.Index >= 0)
  16. {
  17. BandBase c = Items[e.Index] as BandBase;
  18. Image img = this.GetImage(c == null ? 76 : RegisteredObjects.FindObject(c).ImageIndex);
  19. string text = "";
  20. if (c == null)
  21. text = Res.Get("Misc,None");
  22. else
  23. {
  24. text = c.Name;
  25. if (c is DataBand)
  26. text += ": " + c.GetInfoText();
  27. else if (c is DataFooterBand)
  28. text += ": " + c.DataBand.GetInfoText();
  29. else if (c is GroupFooterBand)
  30. text += ": " + (c.Parent as GroupHeaderBand).GetInfoText();
  31. }
  32. this.DrawImageAndText(e, img, text);
  33. }
  34. }
  35. public BandComboBox()
  36. {
  37. DrawMode = DrawMode.OwnerDrawFixed;
  38. }
  39. }
  40. }