views:

75

answers:

2

I am trying to update a single motor control application into a program that controls an unknown number of motors(adding motor controls at runtime). The old application was written very statically and relied on windows form designer to generate its views. I am trying to refactor the designer code to basically just display multiple occurrences each inside a Tab Page. I am already running into errors with Windows form designer. When I try and pull the initialization of components out into their own methods I get an error:

Method 'System.Windows.Forms.Form.InitializeForceIsMaintained' not found.   

How do I tell C# I want to use the local method and not some inherited method?

I'm calling InitializeForceIsMaintained like so

private Void InitializeComponent()
{
    this.InitializeForceIsMaintained();
}

and

private void InitializeForceIsMaintained()
        {
            // 
            // forceIsMaintained
            // 
            this.forceIsMaintained.AutoReset = false;
            this.forceIsMaintained.Interval = 8000;
            this.forceIsMaintained.SynchronizingObject = this;
            this.forceIsMaintained.Elapsed += this.forceIsMaintained_Elapsed;
        }
A: 

Can you inherit your objects from System.Windows.Forms.Form and then override the method in question? Then it would choose to use yours instead of the default one in the Forms.Form class.

rwmnau
+1  A: 

Don't understand the complete problem, but you should never modify the designer code as its generated, so you'll only either lose your changes or break the designer.

Cookey
Excellent point: The designer code *looks* like C# but should never be edited or modified, because the Visual Designer *parses* the code in order to do the editing. It's more like a really weird serialization format that happens to also be compilable.
Bevan