Datagridview更改特定单元格的显示成员 [英] Datagridview change display member for specific cell

查看:88
本文介绍了Datagridview更改特定单元格的显示成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它使用带有数据源的Datagridview。每列都有一个指定的显示成员。在一列上,显示构件是"描述"。这是列中显示的项目的理论描述。但在一些
的情况下,需要描述覆盖,但必须保持理论描述。

I have a application that uses a Datagridview with datascource. Each column has a specified displaymember. On one column the display member is "Description". This is a theoretical description of the item displayed in the column. But in some cases a description overwrite is required, but the theoretical description must be maintained.

我可以在需要时为单个文本框设置显示成员吗?

Can I set the display member for a single textboxcell when required?

If Not Item.OverwiteDescription is Nothing then

    Cell.Displaymember = "OverwiteDescription"

End If

但我在文档中找不到任何关于此的内容。  https://msdn.microsoft.com/en-us/library/system.windows.forms .datagridviewtextboxcell(v = vs.110).aspx

But I can't find anything in the documentation about this. https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewtextboxcell(v=vs.110).aspx

我相信对于一个组合单元这是可能的吗?但不是文本框?  https:// msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcell(v=vs.110).aspx

I believe for a combobx cell this is possible? But not a textbox? https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcell(v=vs.110).aspx




推荐答案

你好,

你是对的,DataGridView让它的DataSource设置了它不可能。你需要做的是有一个未绑定的DataGridViewTextBoxColumn来处理你所追求的以及绑定列。这样做的逻辑是你加载
的数据。如果您希望用户更改此列的值,因为它现在与绑定数据分离,可能会出现复杂性。

You are correct, with a DataGridView having it's DataSource set it's not possible. What you would need to do is have a unbound DataGridViewTextBoxColumn to handle what you are after along with the bound columns. The logic for this would be were you load the data. The complexity may come if you want the user to change values for this column as it's now detached from the bound data.


这篇关于Datagridview更改特定单元格的显示成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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