开发者

Winforms Designer Error "An error occured while parsing EntityName"

开发者 https://www.devze.com 2023-01-18 08:46 出处:网络
I\'am using a custom control code for my winforms application to create a custom colored progressbar. I can build it, and it works fine, BUT everytime I try to use designer, it crashes. \"An error occ

I'am using a custom control code for my winforms application to create a custom colored progressbar. I can build it, and it works fine, BUT everytime I try to use designer, it crashes. "An error occured while parsing EntityName"

  • If I add from the toolbox, this is what I get.

  • If I insert a progressbar, then rewerite the code for my control (replace progressBar with progressBarEx), then this is what I get.

The code:

using System.Drawing;
using System.Windows.Forms;

namespace Crystal
{
public class ProgressBarEx : ProgressBar
{
开发者_JAVA技巧    private SolidBrush brush = null;

    public ProgressBarEx()
    {
        this.SetStyle(ControlStyles.UserPaint, true);
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        if (brush == null || brush.Color != this.ForeColor)
            brush = new SolidBrush(this.ForeColor);

        Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
        if (ProgressBarRenderer.IsSupported)
            ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);
        rec.Width = (int)(rec.Width * ((double)Value / Maximum)) - 4;
        rec.Height = rec.Height - 4;
        e.Graphics.FillRectangle(brush, 2, 2, rec.Width, rec.Height);
    }
}

}


Dominik aka galaris provided his answer in his own question. I cleaned it up and moved it here:

The solution can be found here. The problem is that one of my folders contained a & character. Moving the project to the desktop folder solved the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号