asp.net 3.5中的Windows窗体 [英] windows forms in asp.net 3.5
问题描述
嘿,我的问题可能很愚蠢,但请给出答案.........
问).让我们有2种形式[form1和form2]
在form1中,我们有一个treeview控件,其中包含[共享文档和主要文档]
作为父节点.以及包含文件菜单的菜单条,其中有一个链接可以打开表格2 ....
在form2中,我们有一个文本框和按钮[确定] .....
问题如下..每当我们在文本框中编写文本时,如果两个父节点都必须以form1形式出现,则该文本必须作为子节点出现在Form1中?那怎么办呢?
请为此我急需答案.........
hey guys my question may be silly but please give your answers please .........
Q). lets have 2 forms [ form1 and form2 ]
in form1 we have a treeview control where it contains[ shared doccs and main docs ]
as parent nodes. and a menu strip containing file menu where we have a link to open form 2 ....
in form2 we have a textbox and button [ok].....
the question as follows.. when ever we write a text in the textbox the text must be appeared in the form1 as a child node of any if the two parent nodes? so how to do it?
please i badly need the answers for it............
推荐答案
在Form2中创建一个在Form1中处理的事件. br/> 文本准备就绪时,在Form2中向事件发出信号,并在自定义EventArgs中传递新文本.
在Form1事件处理程序中,将文本添加到树视图中.
表格2:
Create an event in Form2, that is handled in Form1.
Signal the event in Form2 whenever the text is ready, and pass the new text through in a custom EventArgs.
In the Form1 event handler, add the text to the tree view.
Form2:
public event EventHandler<ChangedArgs> Changed;
private void butGo_Click(object sender, EventArgs e)
{
EventHandler<ChangedArgs> ch = Changed;
if (ch != null)
{
ch(this, new ChangedArgs(tbData.Text));
}
}
}
public partial class ChangedArgs : EventArgs
{
public string strData;
public ChangedArgs(string str)
{
strData = str;
}
}
表格1:
Form1:
private void frmTextBox_Load(object sender, EventArgs e)
{
otherForm.Changed += new EventHandler<ChangedArgs>(Changed);
otherForm.Show();
}
private void Changed(object sender, ChangedArgs e)
{
if (e != null)
{
Console.WriteLine(e.strData);
}
}
[edit] ChangedArgs在Click处理程序中被吞噬为HTML标记,从而导致编译错误.哎呀! -OriginalGriff [/edit]
[edit]ChangedArgs swallowed as HTML Tag in Click handler, causing compilation error. Ooops! - OriginalGriff[/edit]
这篇关于asp.net 3.5中的Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!