.NET / C#绑定的IList<字符串>以一个DataGridView [英] .NET / C# Binding IList<string> to a DataGridView

查看:146
本文介绍了.NET / C#绑定的IList<字符串>以一个DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的IList<字符串> 从函数返回(如可变LST),我设定,然后我

I have an IList<string> returning from a function (as variable lst) and I set and then I

this.dataGridView1.DataSource = lst;

数据网格添加一列标记的长度,然后列出每个串的长度。 我如何让它只列出了弦?

The datagrid adds one column labelled Length and then lists the length of each string. How do I make it just list the strings?

推荐答案

您真的很需要那有无字符串属性对象的列表。随着.NET 3.5,你可以欺骗:

You really need a list of objects that have a string property. With .NET 3.5 you could cheat:

.DataSource = list.Select(x=>new {Value = x}).ToList();

否则,创建一个虚拟的类和手动复制数据...

Otherwise create a dummy class and copy the data in manually...

这篇关于.NET / C#绑定的IList&LT;字符串&GT;以一个DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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