簡體   English   中英

如何將 DataGridViewLinkColumn 屬性添加到 DataGridView 中動態生成的列?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM