我设了Public但是就是不能访问,这是主窗口的按钮
private void AdvSer_Click(object sender, System.EventArgs e)
{
if(StateSearchFrm==false)//判断是否有Search实例
{
Search f=new Search(this);
f.Show();
} }这是自窗口的查询按钮
private void Seachbtn_Click(object sender, System.EventArgs e)
{
想在这里引用DataGrid,DataSet,DataAdapter,DataConnection再查询,就是不能引用请帮忙,在父窗口里面我已经设成Public了,为什么呀?
}
private void AdvSer_Click(object sender, System.EventArgs e)
{
if(StateSearchFrm==false)//判断是否有Search实例
{
Search f=new Search(this);
f.Show();
} }这是自窗口的查询按钮
private void Seachbtn_Click(object sender, System.EventArgs e)
{
想在这里引用DataGrid,DataSet,DataAdapter,DataConnection再查询,就是不能引用请帮忙,在父窗口里面我已经设成Public了,为什么呀?
}
public Commitee.CMDataSet cmDataSet;
private System.Windows.Forms.Label Posisionlbl;
private System.Windows.Forms.Label Statelbl;
private System.Windows.Forms.Label Clanlbl;
private System.Windows.Forms.Label Schoolarshiplbl;
private System.Windows.Forms.Label Workspacelbl;
private System.Windows.Forms.Label Unitaddresslbl;
private System.Windows.Forms.Label Unitphonelbl;
private System.Windows.Forms.Label Unitcodelbl;
private System.Windows.Forms.TextBox Statetxt;
private System.Windows.Forms.TextBox Clantxt;
private System.Windows.Forms.TextBox Schoolarshiptxt;
private System.Windows.Forms.TextBox Workspacetxt;
public System.Windows.Forms.TextBox Unitaddresstxt;
private System.Windows.Forms.TextBox Unitphonetxt;
private System.Windows.Forms.TextBox Unitpostcodetxt;
private System.Windows.Forms.Label Memolbl;
private System.Windows.Forms.TextBox Memotxt;
private System.Windows.Forms.Label Grouplbl;
private System.Windows.Forms.TextBox Grouptxt;
private System.Windows.Forms.TextBox IsSCtxt;
private System.Windows.Forms.Label IsSClbl;
private System.Windows.Forms.TextBox Homeaddresstxt;
private System.Windows.Forms.Label Homeadresslbl;
private System.Windows.Forms.La
这是部分代码
public FrmMain myMain;//通过this.myMain来访问父窗体的相关对象//父窗体中(FrmMain)
//创建子窗体
FrmSubWin mySubWin=new FrmSubWin();
mySubWin.myMain=this;//传进父窗体实例
mySubWin.Show();注意,同时需要把父窗体中相关的对象进行public。
对于private System.Windows.Forms.TextBox Homeaddresstxt;控件你可以
public Button txtHOMEADDRESS
{
get
{
return this.Homeaddresstxt;
}
}
方法定义为public就可以了