RadControls version Q2 2011 |
|
.NET version 4.0 |
|
Visual Studio version 2010 |
|
programming language VB |
|
browser support |
all browsers supported by RadControls
|
PROJECT DESCRIPTION
I needed to put a news section in our desktop app to mirror a news feed on our website. The news comes in a data table with a column for description and one for link. I used the following code to make this work. This is very simplified, I just couldn't find a place to do it and figured I'd share.
In the form_load
Dim dt As DataTable = {YOUR DATATABLE}
For x As Integer = 0 To dt.Rows.Count - 1
'Create Link
Dim news As New LinkLabel
news.Text = dt.Rows(x).Item("Description")
news.Links.Add(0, dt.Rows(x).Item("Description").ToString.Length, dt.Rows(x).Item("Link"))
'Add Handler for the Click
AddHandler news.LinkClicked, AddressOf News_LinkClicked
'Add item to Rotator
Dim rditm As New RadHostItem(news)
rtrNews.Items.Add(rditm)
Next
rtrNews.Start()
Then you need to add the function to open the link
Private Sub News_LinkClicked(sender As System.Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
Process.Start(e.Link.LinkData.ToString)
End Sub