如何将 ClassType 字段显示到 DataGridView 中
我有网络服务功能,我正在为我的项目导入该功能。问题是,我有一个方法,它返回(比方说)FirstClass 的数组。它本身包含 SecondClass 的字段类型(成员:名称、值) 我有 DataGridView 和此数组数据源。 问题是,此 MyDataGridView.DataSource = Array 显示 SecondClass 的所有字段值 excat 字段类型。 (显示 Namespace.Class 而不是 Value 字段) 我可以做什么来使 SecondClass 显示 Value 字段。
I have web-service function, which I'm importing for my project. The thing is that, I have method, which returns Array of (let's say) FirstClass. This itself contains field type of SecondClass (Members: Name, Value)
I have DataGridView with This Array DataSource.
The thing is that, This MyDataGridView.DataSource = Array displays all field values excapt field type of SecondClass. (displayed Namespace.Class not the Value field)
what can i make to make Value field of SecondClass show.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以执行以下操作之一:
覆盖
SecondClass
中的ToString
方法。如果您无法以任何方式修改
SecondClass
,请尝试将DataGridView
列绑定到SecondClass.Name
属性。 p>如果这也不起作用,您可以继承
FirstClass
添加一个属性来获取SecondClass.Name
属性的值。You can do one of the following:
Override the
ToString
method in theSecondClass
.If you was unable to modify the
SecondClass
in any way, try to bind theDataGridView
column toSecondClass.Name
property.If that didn't work too, you can inherit
FirstClass
adding a property that gets theSecondClass.Name
property's value.实际上这篇文章帮助
我可以传递给 DataPropertyName,如 FirstClass 字段(SecondClass 类型)Name.Name(第二名称 - SecondClass 属性)
Actually this Article helped
I could pass to DataPropertyName like FirstClass field (SecondClass Typed) Name.Name (Second Name - SecondClass Property)