如何更新和显示现有的Windows窗体

编程入门 行业动态 更新时间:2024-10-10 17:28:20
本文介绍了如何更新和显示现有的Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我有两种形式(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窗体

本文发布于:2023-10-27 04:24:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532304.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:新和   窗体   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!