一次又一次地使Windows窗体无效

问题描述

| 我正在使用此代码绘制一些圆,但是它不断重画和重画,并且即使我尝试5或6,也会出现textBox1.text具有错误的数字格式的错误,并且此错误停止了。
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace terc
{
    /// <summary>
    /// Description of MainForm.
    /// </summary>
    public partial class MainForm : Form
    {
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //
        }






        void Button1Click(object sender,EventArgs e)
        {
            this.Paint += new PaintEventHandler(KresliTerc);
        }

        protected void KresliTerc(object sender,PaintEventArgs e)
        {
            Graphics grfx = e.Graphics;
            int pocet = int.Parse(textBox1.Text);
            label1.Text = pocet.ToString();

            for(int i=1; i <= pocet; i++)
            {
                grfx.FillEllipse(Brushes.Black,ClientSize.Width/2,ClientSize.Height/2,50*i,50*i);
                Invalidate();
            }

        }
    }
}
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)