我使用数据表动态树视图,从数据库中获取所需信息。
现在我正在尝试向treeview添加2列,然后我知道treeview必须在datagrid列上。
所以我搜索了很多并且很困惑。
我使用下面的代码块来生成我的树视图,它就像一个魅力;
$('[class*=fooclass]').on('keydown',this.onKeyDown.bind(this));
然而,正如我所说,我需要使用datagrid再添加2列。
我知道互联网上有一堆控件,但它们都太老了,不能使用上面的代码。
我应该按照哪种方式创建自己的treeviewgrid?
答案 0 :(得分:0)
If you have two more columns in your DataRow object, you could do a couple of things:
You could simply append the additional column's data to the text of the TreeNode.
text += $"\t{rows["extraColumn1"].ToString()}\t{rows["extraColumn2"].ToString()}";
You could add the extra columns to a tool tip. This would require that you add a ToolTip control to the form (named for example toolTip1), and then update the ToolTip on toolTip1
property when the mouse moves over a node. A little bit of work, and you would also want to keep a reference to the two columns of data that you would populate the tool tip with. A quick way to do that would be to set the rows object to the Tag property of the TreeNode.
You could create your own extension of the TreeView control that has two more fields that it could display. This would be quite a bit of work.