C# 数据源中两列的DataPropertyName DataGridViewLinkColumn
我有一个DataGridView,其中包含手动添加的列,例如: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”的列
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列中