在我的自定义控制文件中:
namespace myApp {
public partial class MyStatusBar : Label {
public MyStatusBar () {
InitializeComponent ();
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Dock = DockStyle.Bottom;
}
protected override void OnPaint (PaintEventArgs pe) {
base.OnPaint (pe);
pe.Graphics.DrawRectangle (new Pen (Color.Azure), ClientRectangle);
}
}
}
以我的形式:
MyStatusBar mStatusBarLabel = new MyStatusBar ();
public MCADDrg() {
InitializeComponent ();
this.SetStyle (ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle (ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle (ControlStyles.UserPaint, true);
this.SetStyle (ControlStyles.SupportsTransparentBackColor, false);
this.SetStyle (ControlStyles.Opaque, false);
this.SetStyle (ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle (ControlStyles.ResizeRedraw, true);
splitContainer1.Panel2.Controls.Add (mStatusBarLabel);
splitContainer1.Panel2.MouseMove += Panel2_MouseMove;
}
void Panel2_MouseMove (object sender, MouseEventArgs e) {
if( splitContainer1.Panel2.ClientRectangle.Contains(e.Location))
mStatusBarLabel.Text = "X = " + e.X + " Y = " + e.Y;
}
}
我怎样摆脱这个?我试了一些其他帖子的答案。但是对我来说没有用。假设(实际上)我是新手。