[英]How to add DataGridViewLinkColumn property to dynamically generated columns in DataGridView?
開發環境: c# winforms
,沒有任何數據庫連接
說明:在我的 DataGridView 中,列是動態生成的。在某些時候,某些列需要 DataGridViewLinkColumn 屬性。 我在很多方面都嘗試過,但沒有做到這一點。
我希望這里的人能幫助我:)
提前致謝。
嘗試這個:
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);
您需要關閉AutoGenerateColumns
,然后自己生成每一列。
將普通列設置為DataGridViewTextBoxColumn
類型,然后對於需要鏈接列的列,將它們設置為DataGridViewLinkColumn
類型。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.