Hi happy new year
My problem is the following, in Form1 I have 3 buttons, the 2 at the top open the FrmFruit and the FrmVegetable in the panel, the button next to the text boxes opens the FrmFruit outside of the panel.
If I open the form from the enter button, I enter the data in it and when I enter I send the data from the FrmFruit to Form1 without problem, but if I try it from the FrmFruit open in the panel, no data is passed to me, see if you can help me.
what I need is to be able to send the data from the FrmFruit open in the panel, without it closing or opening another form.
Form1
- public partial class Form1 : Form, Clform
- {
-
- public Form1()
- {
- InitializeComponent();
- }
-
- private void Form1_Load(object sender, EventArgs e)
- {
-
- }
-
- public void ChangeTextBoxText(string text)
- {
- tbxName.Text = text;
- tbxquantity.Text = text;
- }
-
-
- private void btnEnter_Click(object sender, EventArgs e)
- {
- FrmFruit form2 = new FrmFruit ();
- form2.ShowDialog(this);
- }
-
-
- private Form formActived = null;
-
- private void OpenFormPanel(Form FormSon)
- {
- if (formActived != null)
- formActived .Close();
- formActived = FormSon;
- FormSon.TopLevel = false;
- FormSon.Dock = DockStyle.Fill;
- pnlcontent.Controls.Add(FormSon);
- pnlcontent.Tag = FormSon;
- FormSon.BringToFront();
- FormSon.Show();
- }
-
-
- private void btnFruit_Click(object sender, EventArgs e)
- {
- OpenFormPanel(new FrmFruit ());
- }
- }
FormFruit
- public partial class FrmFruit : Form
- {
- public FrmFruit()
- {
- InitializeComponent();
- }
-
-
- private void btnEnter_Click(object sender, EventArgs e)
- {
- Iform formInterface = this.Owner as Iform;
-
- if (formInterface != null)
- formInterface.ChangeTextBoxText(tbxNameFruit.Text, );
- formInterface.ChangeTextBoxText(tbxquantityFruit.Text);
- }
- }