Datagrid >> XML >> Website Hyperlink
I have a datagrid that connect to my xml file and displays 3 columns of data, the third which is the website links, how can I have it so those website links become hyperlinks, can someone assist me with this please:
Code:
Imports System.Xml
Imports System.Data
Public Class Form1
Dim ds As New DataSet
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim xmlFile As XmlReader
xmlFile = XmlReader.Create("C:\Projects\Grid Search Application\PhoneData.xml", New XmlReaderSettings())
ds.ReadXml(xmlFile)
DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub btnMobileDeviceFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMobileDeviceFilter.Click
ds.Tables(0).DefaultView.RowFilter = "[Mobile_Phone_Type] like '%" & tbMobileDevice.Text & "%'"
DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub btnSimType_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimType.Click
ds.Tables(0).DefaultView.RowFilter = "[SIM_Type] like '%" & tbSIMType.Text & "%'"
DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub btnWebsiteLinkFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWebsiteLinkFilter.Click
ds.Tables(0).DefaultView.RowFilter = "[Website_Link] like '%" & tbWebsiteLink.Text & "%'"
DataGridView1.DataSource = ds.Tables(0)
End Sub
Everything runs smoothly, I just want to make the website links hyperlinks.
Can I use this in my code?
http://www.vbforums.com/showthread.p...ight=hyperlink
Thank you.
Re: Datagrid >> XML >> Website Hyperlink
The trick is to create your datagridview columns before binding the table and specifying their data member ...
vb.net Code:
Dim dt As New DataTable
dt.Columns.Add("Links", GetType(String))
dt.Rows.Add({"http://www.google.co.uk"})
dgv.Columns.Add(New DataGridViewLinkColumn)
dgv.Columns(0).DataPropertyName = "Links"
dgv.Columns(0).Name = "Links"
dgv.DataSource = dt
Don't forget though that this only gives the appearance of a hyperlink. As with link labels you still need to program the result of a click eg. launching a browser.