开发者

How to add DataGridViewLinkColumn property to dynamically generated columns in DataGridView?

Developing In: c# winforms without any Database Connections

Description: In my DataGridView, columns were dynamically generated.At some point some of the columns need to be DataGridViewLinkColumn property. I was tried in many ways but didn't achive this.

I hope someone from here w开发者_Go百科ould help me :)

Thanks In Advance.


Try this:

       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);


You will need to switch off AutoGenerateColumns, then generate each column yourself.

Setup the normal columns as type DataGridViewTextBoxColumn, then for the columns which need to be Linked columns set them up as type DataGridViewLinkColumn.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜