Click here to Skip to main content
15,077,377 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have a datagridview in which i have a specific column which is in datagridviewlinkcell type. Before i let users to proceed with their logics, i want to check if they have click the link cell.
I stumbled upon the DataGridViewLinkCell.LinkVisited property but the weird thing is I can make the extension/property comes out when i hit the "dot" button.
I found the article by Microsoft but it seems to be not providing any example needed.
Below are some of the codes I have:
C#
if(dgvMenu.Rows[_selectedIndex].Cells[3].GetType() == typeof(DataGridViewLinkCell))
{
   string value = dgvMenu.Rows[_selectedIndex].Cells[3].Value.ToString(); //problem here
}


I have temporary put the Value as placeholder. I hover over the "Cells" using debug I found LinkVisited property is there but I cannot access the property when I write my codes upon "dot" after the "3".

Any help would be appreciated. Thank you.

What I have tried:

1. Look into Microsoft documentation but to no avail. DataGridViewLinkCell.LinkVisited Property (System.Windows.Forms) | Microsoft Docs[^]
2. Search online for example but cannot find appropriate information.
Posted
Updated 27-Nov-20 0:49am

1 solution

Assuming you're using an up-to-date compiler:
C#
if (dgvMenu.Rows[_selectedIndex].Cells[3] is DataGridViewLinkCell linkCell)
{
   bool linkVisited = linkCell.LinkVisited;
   ...
}
For older compiler versions:
C#
var linkCell = dgvMenu.Rows[_selectedIndex].Cells[3] as DataGridViewLinkCell;
if (linkCell != null)
{
   bool linkVisited = linkCell.LinkVisited;
   ...
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900