绑定到对象的“ ToString”的DataGridView。属性 [英] DataGridView binding to an object's "ToString" property

查看:68
本文介绍了绑定到对象的“ ToString”的DataGridView。属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将对象列表绑定到Winform DataGridView。这工作正常,并且在对象上为每个属性都有一列。现在,我已覆盖基于属性输出文本的对象上的 ToString。我现在想更改DataGridView,使其具有绑定到对象的 ToString属性的单个列。这可能吗,到目前为止我还没有找到一种方法。

I am binding a list of objects to a Winform DataGridView. This works fine and has a column for each property on my object. I have now overridden the "ToString" on the object that outputs text based on the properties. I would now like to change my DataGridView so that it has a single column that binds to the "ToString" property of my object. Is this possible, as so far I’ve not found a way to do this.

推荐答案

我设法通过以下方法解决了这个问题此链接:绑定字符串列表

I managed to fix this by following this link: Binding List Of String

解决方案是包装每个字符串,以便绑定机制知道要绑定的内容。

The solution was to wrap each string so that the binding mechanism knew what to bind.

这篇关于绑定到对象的“ ToString”的DataGridView。属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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