hey anyone tell me how to call a method in FORM class from another class but both under same namespace.i have some text information which is to be displayed in the textbox through from class by calling a method in form class.i'm ew C# can anyone help me out. i tried in all d ways i could...but no use...its screwing my mind...please someone help me out...
thanks in advance........
Loading
ShankeyPosted Nov 30, 2010, 1:57 AM
to call a method of a class in your form class, you must create an object of that other class in form class and then call the method using object.methodname(); if the method is not a static method. but if the method is a static method then you can call using the otherclassname.methodname();
Karthik AgarwalPosted Nov 30, 2010, 4:50 AM
sry yar i was thinking that i gave enough explanation for the pblm.if u hav askd i could hav told u.anyway sry.here is my code..
class FORM1 : Form
{
public void enable()
{
//1st method which i want to call from another class
}
public void display()
{
//2nd method which i want to call from another class
}
}
class buffer : signal
{
protected override Analyse()
{
//from here i want to call two functions in form class
}
}
now i told u every thing right please reply me......
Sam HobbsPosted Nov 30, 2010, 4:37 AM
CrishPosted Nov 30, 2010, 4:12 AM
To solve this problem you can use
http://stackoverflow.com/questions/2950326/calling-a-function-in-the-form-class-from-another-class-c-net
this link for Calling a method in FORM class from another class.
Karthik AgarwalPosted Nov 30, 2010, 3:43 AM
sry to say u, but i could not understand what u hav explained can u please elaborate it by giving some example.
Sam HobbsPosted Nov 30, 2010, 3:25 AM
If the form is the currently active form for the application then you can use Form.ActiveForm to get a reference to the form and you woud need to cast that reference to the form class for your application.
Karthik AgarwalPosted Nov 30, 2010, 2:05 AM
i want to call a method in FORM class from another class.
i tried that way but when i try creating an object of another class it is sayng dat no constructor in this class takes zero arguments.what shall i do now? the other class from where i want to call a function in FORM class is already inherited from another class(which is not FORM class).....