使datagridview显示为treeview [英] Making the datagridview display to treeview

查看:97
本文介绍了使datagridview显示为treeview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被要求制作一个datagridview,显示来自父母>子父母>孩子的表格的层次结构。

我不知道如何在这里张贴图片以便给你一个清楚地看到我想要做的是,想象一个ms访问数据库有3个名为Parent,Sub-parent和child的表。 Parent位于层次结构的顶部,使用外键连接到Sub-Parent。当Sub-Parent表连接到Child表时,Sub-Parent连接到Parent表的方式相同。



访问,当您查看父表时,只要它与主键对应,您就可以下拉它以查看子父数据行,直到子数据行。



你看,我想把它重新塑造成视觉基本风格。我在这里看到了一些可下载的treeview示例程序,但它对我来说太高级了,我学习并使用了一些我没有一点线索的css / wpf。

解决方案

< blockquote>据我了解你的问题:

TreeView-Control无法直接连接到你的数据表。您需要做的是:

- 根据您的数据结构创建TreeNodes(并给它们相应的名称)。如果结构总是相同的话,这可以手动完成(使用Control-Designer)。或者,如果结构不同,必须动态完成。这样工作如下:

- 添加一个TreeNode并将其命名为

- 选择此TreeNode并添加所有必需的子节点并命名它们。

- 选择这个TreeNode.SubNode并添加所有必需的子节点并命名它们。

- 依此类推。



你觉得吗?你可以这样试试吗?


I am asked to make a datagridview that shows the hierarchy of tables from parents>sub-parents>child.
I don't know how to put up a picture here so to give you a clear view of what I want to make is, imagine an ms access database with 3 tables named "Parent","Sub-parent" and "child". "Parent" is in the top of the hierarchy, connected to "Sub-Parent" with a foreign key. While the "Sub-Parent" table connected to the "Child" table, the same way "Sub-Parent" is connected to "Parent" table.

In the access, when you looked at the "Parent" table, you will be able to drop-down it to see the "Sub-Parent" data row until the "Child" data row whenever it corresponds with the primary key.

You see, I want to recreate that into visual basic style. I saw some downloadable treeview sample progs here but it is too advanced for me to study and uses some css/wpf thing that I don't have a single clue about.

解决方案

As I understand your problem :
The TreeView-Control could not be directly connected to your datatable(s). What you have to do is the following :
- according to the structure of your data create the TreeNodes (and give them the corresponding Name). This could be done manually (with the Control-Designer) if the structure is allways the same. Or it must be done dynamicly if the structure is different. This works like this :
- Add a TreeNode and Name it
- select this TreeNode and add all necessary sub-Nodes and Name them.
- select this TreeNode.SubNode and add all necessary sub-Nodes and Name them.
- and so on.

Do you think that you could try it like this ?


这篇关于使datagridview显示为treeview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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