如何从Treeview获取值并将其分配给GridView [英] How to get Values from Treeview and assign to GridView

查看:105
本文介绍了如何从Treeview获取值并将其分配给GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从xml源填充的TreeView,在从节点上选择值后加载Treeview之后,相应的值应在网格内绑定.

I have a TreeView populating from xml source,after loading the Treeview on selecting the values from the node the corresponding values should get bind inside the grid.

推荐答案

首先阅读 TreeView [GridView [
Start by reading the docs for the TreeView[^] and GridView[^] classes and learning how to adapt those examples to meet your own needs.

If you want a more specific answer then you''ll need to post a more specific question.


以下是基础知识;

Here is the basics;

private void readAndWrite()
{
//Read a value from Treeview
int theNode = 1;
String theValue = treeView1.Nodes[theNode].Text;

//set a value in a DataGridView
int theRow = 10;
int theCol = 5;
dataGridView1.Rows[theRow].Cells[theCol].Value = theValue;
}


这是一个更好的问题.

要在TreeView中显示数据,您可以使用
XDocument [^ ](或.Net中的任何其他XML解析类)以加载XML文件,解析出节点结构,然后创建节点并将其添加到电视.另外,.Net 4似乎具有数据绑定 [ ^ ]可以为您完成工作的控件上的属性.

该文档向您展示了如何手动创建和添加节点.然后,您可以处理AfterSelect事件,以更改应用程序其他位置显示的内容.我真的没有那么多地使用网格,所以我无法为您提供帮助.抱歉:(
That''s a much better question.

To show the data in the TreeView you can either use the XDocument[^] (or any of the other XML Parsing classes in .Net) to load the XML file, parse the node structure out and then create and add nodes to the TV. Alternatively it looks like .Net 4 has a DataBindings[^] property on Controls that may do the job for you.

The docs show you how to create and add nodes manually. Then you can handle the AfterSelect event to change what''s shown elsewhere on your app. I really don''t use grids that much so I can''t help you with that one. Sorry :(


这篇关于如何从Treeview获取值并将其分配给GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆