I have a main form which is called form
and a second form called form2
. Form
contains a button with a coded function inside. Now on my form2
I have the same button which performs the same function on form
or which I want it to perform the same function as form1.
On form2
I have created a button of which I want it to use the same function from the form1
. Now I want to be able to click the button from form2 and it calls the button funtion from form1.
I have done this but I don't know how I can make it work
Form1 (mainform)
public Button newButton
{
get
{
return btnNewfile;
}
}
public void SetLanguage(string cbolang)
{
cboLanguage.SelectedValue = cbolang;
}
Form2
public frmMain_Page _frmMainform;
public FrmLanguage(frmMain_Page _frmMainform)
{
InitializeComponent();
this._frmMainform = _frmMainform;
}
public frmMain_Page _Main
{
get;
set;
}
//from this button I can't get the main button from the main form
private void btnCreatFile_Click(object sender, EventArgs e)
{
_frmMainform.newButton.btnNewfile;
//Error 19 'System.Windows.Forms.Button' does not contain a definition for 'btnNewfile' and no extension method 'btnNewfile' accepting a first argument of type 'System.Windows.Forms.Button' could be found (are you missing a using directive or an assembly reference?)
}
Aucun commentaire:
Enregistrer un commentaire