0

这是一个非常基本的问题 - 我在 VB.net WinForms 应用程序中有一个 List(Of MyClass)。

MyClass 包含两个公共字符串属性。

我想将 List(Of MyClass) 绑定到 WinForm 上的普通 MS GridView,以便添加到 List(Of MyClass) 的项目出现在 MS GridView 中。

4

1 回答 1

0

我不熟悉 vb 语法,但在 c# 中,您可以轻松地将列表作为数据源绑定到 datagridview。像这样的东西(c#):

        List<Class2> list = new List<Class2>();
        list.Add(new Class2 { test1 = "test", test2 = "test2" });
        list.Add(new Class2 { test1 = "test", test2 = "test2" });
        list.Add(new Class2 { test1 = "test", test2 = "test2" });
        list.Add(new Class2 { test1 = "test", test2 = "test2" });
        list.Add(new Class2 { test1 = "test", test2 = "test2" });
        list.Add(new Class2 { test1 = "test", test2 = "test2" });

        dataGridView1.DataSource = list;

我认为你在 vb.net 中重现它并不难。

于 2012-08-30T22:37:53.567 回答