TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Alynson Torres
1.6k
149
2.1k
Pass data between open C # Forms
Jan 3 2021 8:18 PM
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;
}
//BUTTON OPEN THE FORM
private
void
btnEnter_Click(
object
sender, EventArgs e)
{
FrmFruit form2 =
new
FrmFruit ();
form2.ShowDialog(
this
);
}
//METHOD TO OPEN THE FORM ON THE PANEL----------------------------------------------------------
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();
}
// BUTTON OPEN THE FORM ON THE PANEL
private
void
btnFruit_Click(
object
sender, EventArgs e)
{
OpenFormPanel(
new
FrmFruit ());
}
}
FormFruit
public
partial
class
FrmFruit : Form
{
public
FrmFruit()
{
InitializeComponent();
}
// ENTER BUTTON
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);
}
}
Reply
Answers (
4
)
Capture Image using Asp.net Button C#
Print Crystal Report directly when press save button .