开发者

DatagridView concat strings

I have a datagridview with a column "name". There are about 50 rows with names. I would like to get all the names in one delimited sting, like this "David, john, Kim". Do I have to loop on all the rows in the grid for 开发者_开发技巧this or there is something cleaner without looping?

I'm using framework 4.0, c# winforms.

Thanks.


with help of LINQ:

string names = string.Join(", ", grid.Rows.OfType<DataGridViewRow>()
               .Select(i => i.Cells["name"].Value.ToString()).ToArray())
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜