你如何进行数据绑定到System.Windows.Forms.Treeview控制?绑定、数据、System、Treeview

2023-09-02 10:23:56 作者:人贱无极限越贱越亮点

我看着这个控件,它似乎缺乏标准的.NET数据源和数据成员属性绑定。难道这不是控制绑定?我可以写一些自定义函数填充树视图,从给定的数据源,我想,并在必要时嵌入的数据对象,而是认为最佳实践?或者每个人都简单地使用第三方TreeView控件?

I'm looking at this control, and it seems to be lacking the standard .net "datasource" and "datamember" properties for databinding. Is this control not bindable? I can write some custom function that populates the treeview from a given data source, I suppose, and embed data objects as necessary, but is that the 'best practice'? Or does everyone simply use a 3rd party treeview control?

推荐答案

您是在正确的没有数据绑定。的原因是,的TreeView是分级的数据结构。也就是说,不是一个直列表。其结果是,数据绑定选项无效说一个列表结构。

You are correct in that there is no data binding. The reason being is that TreeViews are hierarchical data structures. That is, not a straight list. As a result the databind option is invalid to say a List structure.

可悲的是它创建自己的填充方法或购买第三方控件(这到底会有自己的填充的方法。)

Sadly it's creating your own populate methods or buying 3rd party controls (which in the end will have their own populate methods.)

下面是上绑定分层数据。