Ich habe eine Klasse CircularButton, die von Knopf und Knopf erstreckt, die den Text nicht angezeigt wird, mit oder ohne Backcolor. Kann nicht herausfinden, was passiert:Warum zeigt meine Schaltfläche den Text nicht an?
public class CircularButton : Button {
public CircularButton(Color c, String text){
Font = new Font("Arial", 20f, FontStyle.Bold);
BackColor = c;
Text = text;
}
public Action<PaintEventArgs> DoPaint { get; set; }
protected override void OnPaint(PaintEventArgs e) {
if (DoPaint != null) { DoPaint(e); }
}
}
//make a new circular button, the text is just a letter.
CircularButton btn = new CircularButton(Color.Red,"A");
btn.Bounds = new Rectangle(0, 0, 50, 50);
btn.Enabled = false;
btn.DoPaint = delegate(PaintEventArgs p){
Graphics graphics = p.Graphics;
SolidBrush brush1 = new SolidBrush(SystemColors.ButtonFace);
graphics.FillRectangle(brush1, 0, 0, btn.Width, btn.Height);
SolidBrush brush2 = new SolidBrush(btn.BackColor);
graphics.FillEllipse(brush2, 0, 0, btn.Width, btn.Height);
};
Ihre Farbe jeden Text tut schreiben .. – BugFinder
Ich vermute, dies WinForms ist, warum nicht nur die Region Eigenschaft einer Standard-Taste, um es zu einem Kreis Clip verwenden? –
@ZoharPeled Da ich aus Java komme, benutze ich die .net-Bibliotheken, kenne die meisten noch immer nicht. – tomyforever