2010-11-30 42 views

回答

1

在创建缓冲类,你必须通过引用Form1的实例,然后使用该实例。示例代码:

class Form1 : Form 
{ 
    public void InitBuffer() 
    { 
    Buffer b = new Buffer(this); 
    ... 
    } 

    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 
{ 
    private Form1 form; 

    public Buffer(Form1 parent) 
    { 
    form = parent; 
    } 
    protected override Analyse() 
    { 
    form.enable(); 
    form.display(); 
    } 
} 

您无法抓住Form1的真实实例,就像从那里冒出来一样。

相关问题