Re: Method '*****' not found. Warning displayed in 'Form1.cs [Design]' pane
- From: "Peter Duniho" <no.peted.spam@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 26 Sep 2009 12:34:45 -0700
On Sat, 26 Sep 2009 11:30:52 -0700, anthony <anthonysvalencia@xxxxxxxxx> wrote:
[...]
Warning message: Method 'System.Windows.Forms.Form.DisplayMessage' not
found.
Comment: I know that DisplayMessage is not a method of the Form
object.
But it needs to be for the Designer to know what to do with it.
The file where you're trying to add the call site to your new method is a special file: in addition to being compiled by the C# compiler to create your Form sub-class, it is parsed by the Visual Studio Designer as part of showing you the graphical representation of the object and allowing you to edit it.
If the Designer comes across something it doesn't recognize, it has no way to know what to do with it. So, while the compiles and runs okay (or at least, in the example you gave it should), when it comes time for you to try to edit the control graphically with the Designer, it emits the warning you describe, explaining to you that it found something it doesn't understand.
I am trying to get Form1 class to define a new form in
adddition to those derived from Form. I thought that was what the
following line was doing from Form1.cs:
public partial class Form1 : Form {
Well, yes...the ": Form" does indicate to the C# compiler that your new Form1 class inherits the Form class. But the C# compiler isn't what's giving the message.
Apparently, I do not know how to add additional methods to a class
which was derived from another class.
You are adding the method just fine. It's your use of the method that is causing problems.
In any event, this is what I
wish to do. Does someone know how to do this? Also, I know that this
method does not have a purpose here. It is going to be substituted
with another method, but I chose to write something smaller and
simpler to generally illustrate the issue I am having.
As Jeff says, you should not be editing the *.Designer.cs file. It is not literally possible to do what you seem to be wanting to do, while still preserving the Designer's ability to work with your class correctly. It's not clear from your question why you want to insert the method call in the *.Designer.cs file, nor for that matter why you have declared a control member in the regular *.cs file (where the Designer can't see it...not that this issue is connected to the specific question you're asking).
It's possible that you should simply call the method from your own construction, after the call to InitializeComponent(), or that you should override the OnFormLoad() or OnShown() methods and call the method in the override. Or it's possible there's some entirely different thing you should be doing. If you can describe in a clear, specific way what it is you're actually trying to accomplish, we might be able to offer useful advice along those lines.
But whatever it is you're really trying to do here, manually writing code in the *.Designer.cs file isn't the right way to do it.
Pete
.
- Follow-Ups:
- Re: Method '*****' not found. Warning displayed in 'Form1.cs [Design]' pane
- From: Family Tree Mike
- Re: Method '*****' not found. Warning displayed in 'Form1.cs [Design]' pane
- References:
- Prev by Date: Re: Method '*****' not found. Warning displayed in 'Form1.cs [Design]' pane
- Next by Date: Re: Method '*****' not found. Warning displayed in 'Form1.cs [Design]' pane
- Previous by thread: Re: Method '*****' not found. Warning displayed in 'Form1.cs [Design]' pane
- Next by thread: Re: Method '*****' not found. Warning displayed in 'Form1.cs [Design]' pane
- Index(es):
Relevant Pages
|
Loading