我想在我的Windows窗体应用程序中添加普通的工具箱按钮,它覆盖了窗体的onpaint方法,将窗体的形状更改为椭圆形。当我在load事件中添加创建新按钮的代码时,根本没有可见的效果,我没有看到任何按钮。
请协助我如何使用图形和常规控件。
我在这里粘贴代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace gadget2
{
public partial class Form1 : Form
{
Button[] b = new Button[3];
GraphicsPath shape = new GraphicsPath();
public Form1()
{
InitializeComponent();
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
shape.AddEllipse(50, 50, 200, 200);
this.Region = new System.Drawing.Region(shape);
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 3; i++)
{
b[i] = new Button();
b[i].AutoSize = false;
b[i].Width = 100;
b[i].Height = 100;
b[i].Location = new Point(255, 70 + i * 30);
this.Controls.Add(b[i]);
b[i].Show();
b[i].BackColor = Color.Black;
b[i].BringToFront();
}
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Mayank");
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("Mayank");
}
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show("Mayank");
}
}
}