来自不同事件的呼叫方法。(Call Method from a Different Event. Button Click. C#)
我正在使用VS2005,试图制作WinForms。 我想知道如何将方法从不同的事件调用到另一个事件。 像这样的东西:
private void button3_Click(object sender, EventArgs e) { MessageBox.Show(e.Node.Text); } private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { string testMod = e.Node.Text; }
所以这就是我想要做的,在选择一个节点后,当我点击button3时,会出现一个消息框。 实际上,这是我真正想要做的简化版本(在特定应用程序中执行文件),但我想逐步理解它,因为我对这件事情并不完全了解。
如果我缺少任何细节,请告诉我。 谢谢。
I'm using VS2005, trying to make WinForms. I was wondering how to call methods from a different event to another event. Something like this:
private void button3_Click(object sender, EventArgs e) { MessageBox.Show(e.Node.Text); } private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { string testMod = e.Node.Text; }
So this is what I wanted to do, after selecting a node, when I click button3, a message box would appear. Actually, this is a simplified version of what I really wanted to do (executing a file within a particular application) but I want to understand it step-by-step since I'm not entirely knowledgeable about this thing.
Let me know if I'm lacking any details. Thanks.
原文:https://stackoverflow.com/questions/28597587