c# - Adding a circular button to a Windows Form -
I have created a round button in a windows form. The button is fine. The only problem is that I want a different color for the background, so I'm setting up Bangalore in GoldenRoad. However, it only creates a "goldenrod" cube around the circular button ... how do I make it, so that only the button becomes colored? You need to fill Then make sure to remove the Public Mainstream () {Initial Group (); MyButtonObject start = new myButtonObject (); EventHandler My Handler = New Event Handler (Startcall); Start.Click + = myHandler; Start.Location = New system. Drawing Points (5, 5); Start.Size = New System Drawing. Size (101, 101); Start.BackColor = System.Drawing.Color.Goldenrod; This.Controls.Add (start); `} Zero start_Click (Object Sender, System.EventArgs e) {MessageBox.Show (" Start "); } Public category myButtonObject: UserControl {// Draw new button. Secure Override Zero OnPaint (PaintEventArgs E) {Graphics Graphics = E. Graphics; Pen myPen = new pen (color black); // Draw a button as a circle graphic. Dryllepse (MyPene, 0, 0, 100, 100); myPen.Dispose (); }}
Ellipse
Onpan () drawing during the drawing.
Graphics. FillEllipse (Brush Goldnode, new rectangle (0, 0, 100, 100)); Graphics Drylips (MyPain, 0, 0, 100, 100);
start.BackColor property from your
mainform () constructor.
Comments
Post a Comment