|
-
Feb 23rd, 2013, 06:58 AM
#1
Thread Starter
Hyperactive Member
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.
Last edited by jokerfool; Feb 23rd, 2013 at 07:36 AM.
-
Feb 23rd, 2013, 11:55 AM
#2
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.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|