如何更新和显示现有的Windows窗体 [英] how to update and show existing Windows Form
问题描述
大家好,
我有两种形式(Form1和Form2).
Form1包含一个DataGridView控件和添加"按钮.
Form2包含文本框和保存按钮.
这是我的跑步表格
1st:单击添加"按钮时将出现Form1
第二个:Form2将出现在此处,将文本添加到文本框中,当我单击保存"按钮时,它已保存到数据库,而Form1仍停留在数据库中.
我的问题是:我想显示现有的Form1,即具有更新数据的Form1,并且不想显示新的Form1.
希望您能理解这个概念.
请帮帮我
Hi all,
I have two forms (Form1 & Form2).
Form1 contains a DataGridView control and Add button.
Form2 contains TextBoxes & save Button.
Here is my running forms
1st: Form1 will appear when click Add button
2nd: Form2 will appear here adding text to text boxes and when I click the save button it''s saved to database and Form1 still stays there.
My question is this: I want to show existing Form ie Form1 with updating data and dont want to show a new Form1.
I hope you understand the concept.
Please help me out
推荐答案
您只需将其用作:
You just need to use it as:
Form1 m_frm = new Form1();
private void button_add_Click(object sender, EventArgs e)
{
m_frm.Show();
}
在表格1中,您需要处理关闭事件:
and in Form 1 you need to handle the closing event:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
}
Ravi ..
不要用于From.Show仅使用Form.ShowDialog().
通过访问旧表单属性从旧表单获取所有数据..
您想以新形式执行任何操作.以新形式设置属性
.and
在NewForm Load事件中执行操作.
问候,
Saran.t
Hi Ravi..
Dont use for From.Show only use Form.ShowDialog().
get all the Datas from Old Form by Accessing Old Form Properties..
And u want to do any Action in New Form.. Set Perperties in new form
.and
do action in NewForm Load event.
Regards,
Saran.t
这篇关于如何更新和显示现有的Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!