从其他形式创建Treeview节点. [英] Create Treeview node from other form.
本文介绍了从其他形式创建Treeview节点.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用Treeview控件创建了表单,并填充了数据库中的所有值-效果很好.
类别
---子类别
-----项目
要创建新类别(右键单击->新建),将在我创建新类别后显示一个表单-我必须立即在树形视图中添加一个节点.
运行不正常.
如果您有任何样品需要清除,请告诉我...
谢谢与问候,
Senthil .R
I have created form using treeview control and populated all the values from the database - that works fine.
Category
---Sub Category
-----Item
To create New category (right click -> New) a form will be showd, after i created the new category - I have to add a node immediately to the tree view.
It is not working well.
Please let me know if you have any samples to clear this...
Thanks & Regards,
Senthil .R
推荐答案
首先,当他们选择"New"(新建)时,不要尝试以您显示的形式使用它-该表单应该对如何操作一无所知您将显示它收集的数据.相反,请像处理OpenFileDialog表单一样对待"New"表单:创建它,设置它的参数,显示它,然后使用属性告诉您用户做了什么.
First off, don''t try to to it in the form you display when they select "New" - that form should know nothing about how you display the data it collects. Instead, treat the "New" form in the same way that you do a OpenFileDialog form: create it, set up it''s parameters, display it, and then use the properties to tell you what the user did.
MyNewItemForm myForm = new MyNewItemForm()
if (myForm.ShowDialog() == DialogResult.OK)
{
string item = myForm.NewDataEnteredByTheUser;
TreeNode t = new TreeNode(item);
myExistingNode.Nodes.Add(t);
}
希望此 [
Hope this[^] might help you.
这篇关于从其他形式创建Treeview节点.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文