Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 数据源中两列的DataPropertyName DataGridViewLinkColumn_C#_.net_Winforms_Datagridview_Datasource - Fatal编程技术网

C# 数据源中两列的DataPropertyName DataGridViewLinkColumn

C# 数据源中两列的DataPropertyName DataGridViewLinkColumn,c#,.net,winforms,datagridview,datasource,C#,.net,Winforms,Datagridview,Datasource,我有一个DataGridView,其中包含手动添加的列,例如: DataGridViewLinkColumn col = new DataGridViewLinkColumn() { HeaderText = "", DataPropertyName = "PropValue", ReadOnly = true }; this.dataGridResults.Columns.Add(col); 数据源是一个存储过程,它返回一个包含“PropValue”和“PropText”的列

我有一个DataGridView,其中包含手动添加的列,例如:

DataGridViewLinkColumn col = new DataGridViewLinkColumn() { HeaderText = "", DataPropertyName = "PropValue", ReadOnly = true };
        this.dataGridResults.Columns.Add(col);
数据源是一个存储过程,它返回一个包含“PropValue”和“PropText”的列表

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

如果问题解释不清楚,请告诉我

想法

提前感谢您

您可以使用此:

    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);
我是从这个链接得到的:


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