我有一个手动添加了列的DataGridView,例如:
DataGridViewLinkColumn col = new DataGridViewLinkColumn() { HeaderText = "", DataPropertyName = "PropValue", ReadOnly = true };
this.dataGridResults.Columns.Add(col);数据源是一个存储过程,它返回一个列表,其中包含"PropValue“和"PropText”。
我的问题是这个DataGridViewLinkColumn必须显示来自"PropText“的文本,并将其值绑定到"PropValue”。然而,DataPropertyName似乎没有那么灵活,它只绑定到从数据源返回的一种数据类型。
如果问题解释不清楚,请让我知道。
想法?
提前谢谢你
发布于 2012-10-08 18:54:13
我最终使用了两个单独的列,其中一个不可见,其中包含我需要的另一个值。无法将dataset中的两个列绑定到同一个datagridview列。
发布于 2012-10-03 01:36:38
您可以使用以下命令:
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?
https://stackoverflow.com/questions/12695032
复制相似问题