Avatar of DJ P
DJ PFlag for United States of America asked on

Hyper Links In Dataview Grid

Hello experts. I created a form in vb.net (desktop application). I am playing around with a datagridview for the first or second time (newbie). The datagrid connects to a ms access database. The name of the table is called Master. In the table I have a field called File with a data type of hyper link. What I would like is the user click on the hyper link and have it open the appropriate pdf file. For example the pdf file for testing purposes is setup and located at c:\test\201\201.PDF.

In my access table in the field it shows up as the following file:///c:\test\201\201.PDF.  However, when I run my application it shows up in the grid as follows: #file:///c:\Test\201\201.PDF and is grayed out.

My question is how do I get it to just show up with the file name like 201.PDF and have the user click on the hyper link to open the file? Keep in mind I'm fairly new so the simpler the better.
Visual Basic.NETDatabasesMicrosoft Access

Avatar of undefined
Last Comment
Scott McDaniel (EE MVE )

8/22/2022 - Mon
Scott McDaniel (EE MVE )

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks Scott,

I looked at the article and created a test form using the articles code and have a couple of questions. First one is when I copy and paste the code in the article on my test form everything populates in the grid. The links supplied in the grid do not open the page when selecting. I also changed the links just in case to google and the page still does not open. Am I missing something? Also, and here is where I am not great at programming, assuming the links worked how do I tie those to the fields in my access db? The example shows hard coded results with the same link populating the same records in the grid. Hope that makes sense.
Scott McDaniel (EE MVE )

You'd have to handle the CellContentClick event to do anything with the user click.

 Private Sub YourDGV_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles YOURDATAGRIDVIEW.CellContentClick      

If e.ColumnName="NameOfYourLinkColumn" Then
End If
End Sub

Open in new window

Something like that. I haven't used the DataGridView in a while, but I believe you're provided with the RowHandle and Column values from the DataGridViewCellEventArgs.
You'd obviously have to use the name of your DataGridView and Column where indicated

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck