0
votes

I have a problem when I open the designer in Visual Studio for my form

The method 'dragScreen_MouseDown' cannot be the method for an event because a class this class derives from already defines the method.

Only thing I changed was adding a new class named FormBase and get the methods from that class to other forms. Works fine, but designer does not seem to like it.

So in FormBase.cs i got this method:

protected void dragScreen_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        ReleaseCapture();
        SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
    }
}

Then in Main.cs inherit form FormBase.

In the designer it like this:

this.button6.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dragScreen_MouseDown);
2
Please show us the codekwyntes
I have no idea what to show, since the method itself is not the problem. Just the desinger which does not seem to like it. I found similar issue here but it did not work: stackoverflow.com/questions/3165269/…user9373061
So you added a new class like class FormBase : Form1?kwyntes
declare the method with the 'new' keyword, or re-name the method.Danielle Summers

2 Answers

0
votes

I think your problem is that you've derived the partial class MainForm from the class BaseForm, wich is derived from the class System.Windows.Forms.Form. This means the designer generated code i derived from the class System.Windows.Forms.Form but your part of the class is BaseForm. You need to change the designer code from public partial class MainForm : Form to public partial class MainForm : BaseForm.

Am I right??

0
votes

I was able to solve the problem. Due to i had dragScreen in the Main.Designer.cs which cause the first conflict that it does not like looking for method outside the class. So i had to remove those lines and add in the Main.cs constructer:

panel4.MouseDown += dragScreen_MouseDown;