关于在父窗口设置子窗口的关闭事件问题 在子窗口关闭同时,能过 自动 对父窗口里面一个文本控件进行指定的修改。(比如设置Label.Text=“111”) 这个事件该在哪设置?请帮忙讲解下 C#的消息事件不是很清楚,,,VC的倒是知道 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 窗体的formClosed formClosing事件,两个有些区别,看楼主用哪个方便 public class FormChild:Form{ public string LabelText { get;set; } BtnOK_Click() { LabelText = "aaa"; }}public class ParentForm:Form{ void ShowLable() { FormChild child = new FormChild(); if (child.ShowDialg() == DialogResult.OK) { Label1.Text = child.LabelText; } }} private void button3_Click(object sender, EventArgs e) { SubForm _SubForm = new SubForm (); _SubForm.FormClosing += new FormClosingEventHandler(_SubForm_FormClosing); _SubForm.Show(); } void _SubForm_FormClosing(object sender, FormClosingEventArgs e) { SubForm _SubForm=(SubForm)sender; //???? }这样不行? 因为时间的关系,C#才学会1个星期,没去看自定义设置事件问题, 应该有2种方法解决:一种是在父窗口注册子窗口的关闭事件 一种就是 bwangel 说的那样的方法,不过要补充一下,在子窗口里面添加: this.DialogResult = DialogResult.OK; this.Close(); 补充下 : bwangel 开始哪些话是对1,2楼的2位说的 谢谢你的回答让我解决了问题 没有必要加这两句。只要你设定Form的AcceptButton为Btn_OK那个按钮,并设置它的返回值为OK就行了。 winform 怎么跨项目调用窗口? 关于Textbox等待问题 “<” 字符 老是提示“<:” 如何把字符串的第i个字符替换成字符m 阿房收集制作的技术资料电子书 动态的创建属性及编辑的问题 IEnumerable<int>类型获取第一个元素 小菜问题,可不可以从***.cs文件更改一个控件的位置(x,y)? listbox中某些内容太长,listbox宽度不够的时候,如何显示一个小黄条,来显示这一行的内容? 难题,怎么解决,大虾们,帮助 分析一个字符串,返回数组 c#读取数据库加锁。
public class FormChild:Form
{
public string LabelText
{
get;set;
}
BtnOK_Click()
{
LabelText = "aaa";
}
}
public class ParentForm:Form
{
void ShowLable()
{
FormChild child = new FormChild();
if (child.ShowDialg() == DialogResult.OK)
{
Label1.Text = child.LabelText;
}
}
}
{ SubForm _SubForm = new SubForm ();
_SubForm.FormClosing += new FormClosingEventHandler(_SubForm_FormClosing);
_SubForm.Show();
} void _SubForm_FormClosing(object sender, FormClosingEventArgs e)
{
SubForm _SubForm=(SubForm)sender;
//????
}这样不行?
应该有2种方法解决:一种是在父窗口注册子窗口的关闭事件
一种就是 bwangel 说的那样的方法,不过要补充一下,在子窗口里面添加: this.DialogResult = DialogResult.OK;
this.Close();
补充下 : bwangel 开始哪些话是对1,2楼的2位说的 谢谢你的回答让我解决了问题
没有必要加这两句。只要你设定Form的AcceptButton为Btn_OK那个按钮,并设置它的返回值为OK就行了。