FRToolStripDropDown.cs 913 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. namespace FastReport.Controls
  5. {
  6. internal class FRToolStripDropDown : ToolStripDropDown
  7. {
  8. private ToolStripControlHost controlHost;
  9. public FRToolStripDropDown(Control control)
  10. {
  11. controlHost = new ToolStripControlHost(control);
  12. controlHost.AutoSize = false;
  13. Items.Add(controlHost);
  14. AutoSize = false;
  15. control.SizeChanged += Control_SizeChanged;
  16. Control_SizeChanged(control, EventArgs.Empty);
  17. }
  18. private void Control_SizeChanged(object sender, EventArgs e)
  19. {
  20. var control = sender as Control;
  21. controlHost.Size = control.Size;
  22. #if !(WPF || AVALONIA)
  23. Size = new Size(control.Size.Width + 2, control.Size.Height + 2);
  24. control.Location = new Point(1, 1);
  25. #endif
  26. }
  27. }
  28. }