首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >来自数据源中两列的DataPropertyName DataGridViewLinkColumn

来自数据源中两列的DataPropertyName DataGridViewLinkColumn
EN

Stack Overflow用户
提问于 2012-10-03 01:13:46
回答 2查看 1.9K关注 0票数 0

我有一个手动添加了列的DataGridView,例如:

代码语言:javascript
复制
DataGridViewLinkColumn col = new DataGridViewLinkColumn() { HeaderText = "", DataPropertyName = "PropValue", ReadOnly = true };
        this.dataGridResults.Columns.Add(col);

数据源是一个存储过程,它返回一个列表,其中包含"PropValue“和"PropText”。

我的问题是这个DataGridViewLinkColumn必须显示来自"PropText“的文本,并将其值绑定到"PropValue”。然而,DataPropertyName似乎没有那么灵活,它只绑定到从数据源返回的一种数据类型。

如果问题解释不清楚,请让我知道。

想法?

提前谢谢你

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-10-08 18:54:13

我最终使用了两个单独的列,其中一个不可见,其中包含我需要的另一个值。无法将dataset中的两个列绑定到同一个datagridview列。

票数 0
EN

Stack Overflow用户

发布于 2012-10-03 01:36:38

您可以使用以下命令:

代码语言:javascript
复制
    DataGridViewLinkColumn links = new DataGridViewLinkColumn();
    links.HeaderText = "Hello";
    links.UseColumnTextForLinkValue = true;
    links.Text="http://microsoft.com";
    links.ActiveLinkColor = Color.White;
    links.LinkBehavior = LinkBehavior.SystemDefault;
    links.LinkColor = Color.Blue;
    links.TrackVisitedState = true;
    links.VisitedLinkColor = Color.YellowGreen;
    dataGridView.Columns.Add(links);

我是从这个链接得到的:

How to add DataGridViewLinkColumn property to dynamically generated columns in DataGridView?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12695032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档