Accessing Form Methods

0

0 x deadbeef

I have constructed the following form:

public class Form1 : System.Windows.Forms.Form
{
//code here to declare components
....
public void GenerateNodes()
{
FillDirectoryTree(tvwSource, true);
FillDirectoryTree(tvwTarget, false);
}


public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

}


//end of class Form1


.....more code

[STAThread]
static void Main()
{
System.Windows.Forms.Form theForm = new Form1();
theForm.GenerateNodes();

}

I want to call the public methods that I have associated with Form1.
However whenever I try to implement them through an instance of Form1 I
get a build error saying that "System.Windows.Forms.Form" does not
contain a definition for GenerateControls(). Why? Are you not allowed to
access methods of classes that are derived from Form? =\
 
M

mia lanui

right, because you have declared theForm as a System.Windows.Forms.Form, not
a Form1

The method you defined in Form1 is not available in the base class
System.Windows.Forms.Form

Declare as:

Form1 theForm

not:

System.Windows.Forms.Form theForm


HTH
 
0

0 x deadbeef

OMG....duhhh....man I need sleep


mia said:
right, because you have declared theForm as a System.Windows.Forms.Form, not
a Form1

The method you defined in Form1 is not available in the base class
System.Windows.Forms.Form

Declare as:

Form1 theForm

not:

System.Windows.Forms.Form theForm


HTH

I have constructed the following form:

public class Form1 : System.Windows.Forms.Form
{
//code here to declare components
...
public void GenerateNodes()
{
FillDirectoryTree(tvwSource, true);
FillDirectoryTree(tvwTarget, false);
}


public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

}


//end of class Form1


....more code

[STAThread]
static void Main()
{
System.Windows.Forms.Form theForm = new Form1();
theForm.GenerateNodes();

}

I want to call the public methods that I have associated with Form1.
However whenever I try to implement them through an instance of Form1 I
get a build error saying that "System.Windows.Forms.Form" does not
contain a definition for GenerateControls(). Why? Are you not allowed to
access methods of classes that are derived from Form? =\
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top