I have winform in c# that contains datagridview that display table from my database. One of the column is hyperlink data type. But the link doesn't seem to display correctly. for example http://google.com display as #http://google.com# on the column. The question is: How do I remove # from my hyperlink column? How can I make the link accessible? I mean, whenever I click, the link opens in a browser. Here is the example pic
Asked
Active
Viewed 89 times
-1

Sebastian Kaczmarek
- 8,120
- 4
- 20
- 38

Cyb Fyr
- 39
- 1
- 6
-
1Are the pound characters in the database? Should they be in the database? Maybe the issue is the code the incorrectly put the pounds in the database. – jdweng Oct 31 '19 at 10:22
-
Check your database how the links are stored. As for the second part of your question, please check [How to handle the click event of DataGridViewLinkColumn](https://stackoverflow.com/questions/13011407/how-to-handle-the-click-event-of-datagridviewlinkcolumn), Good luck. – Oct 31 '19 at 11:31
-
I checked the database and the link is okay, there are no # sign there. I guess it has problem with the data type, because it is hyperlink on Microsoft access. – Cyb Fyr Oct 31 '19 at 15:15
1 Answers
0
You need to set the link column separately.
I write a working code example, and you could have a look.
Code:
private void Form1_Load(object sender, EventArgs e)
{
DataGridViewLinkColumn col1 = new DataGridViewLinkColumn();
dataGridView1.Columns.Add(col1);
dataGridView1.Columns[0].Name = "Links";
DataGridViewRow dgvr = new DataGridViewRow();
dgvr.CreateCells(dataGridView1);
DataGridViewCell linkCell = new DataGridViewLinkCell();
linkCell.Value = @"http:\\www.google.com";
dgvr.Cells[0] = linkCell;
dataGridView1.Rows.Add(dgvr);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex] is DataGridViewLinkColumn && !(e.RowIndex == -1))
{
Process.Start(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
}
}

Jack J Jun
- 5,633
- 1
- 9
- 27
-
Thank you for your answer. I actually have finally figured it out. The actual problem is on the database and it had fixed. – Cyb Fyr Nov 06 '19 at 09:05