TransparentLabel.cs 772 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace 优软MES.CustomControl.TransparentLabel
  11. {
  12. public partial class TransparentLabel : Label
  13. {
  14. public TransparentLabel()
  15. {
  16. InitializeComponent();
  17. }
  18. protected override void OnPaint(PaintEventArgs pe)
  19. {
  20. pe.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.ClientRectangle);
  21. this.Parent.Controls.Add(this);
  22. this.ImageIndex = 20;
  23. this.BackColor = Color.Transparent;
  24. base.OnPaint(pe);
  25. }
  26. }
  27. }