3

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 would help me :)

Thanks In Advance.

kik
  • 247
  • 1
  • 5
  • 15

2 Answers2

6

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);
Jacob Seleznev
  • 8,013
  • 3
  • 24
  • 34
1

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.

hawbsl
  • 15,313
  • 25
  • 73
  • 114