你如何绑定列表视图中的数据的多个列? [英] How do you bind data to multiple columns in a list view?
问题描述
我有我要绑定到ListView具有多个列的数据源。我如何将数据源绑定到列表视图
I have a datasource that I want to bind to a listview that has multiple columns. How do I bind my datasource to that listview
下面是一些伪code不工作,以帮助说明什么,我试图做的:
Here is some pseudo code that doesn't work to help illustrate what I am trying to do:
MyDataTable dt = GetDataSource();
ListView1.DataBindings.Add("Column1.Text", dt, "MyDBCol1");
ListView1.DataBindings.Add("Column2.Text", dt, "MyDBCol2");
- 编辑 -
-- edit --
对不起,我忘了提及它的WinForms。
Sorry, I forgot to mention it was winforms.
推荐答案
这似乎有在的WinForms ListView控件功能的漏洞(被认为有可能的数据绑定新的WPF列表框)。
It seems there is a lacuna in functionality of WinForms ListView control (thought it's possible to databind new WPF ListBox).
此文章由尼克·卡尼克介绍如何将数据绑定功能添加到从的WinForms ListView控件继承自定义的控制 - 的数据绑定一个ListView 。
This article by Nick Karnik describes how to add databinding capability to custom control inherited from WinForms ListView - Data binding a ListView.
这篇关于你如何绑定列表视图中的数据的多个列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!