當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET LinkLabel.VisitedLinkColor屬性代碼示例

本文整理匯總了VB.NET中System.Windows.Forms.LinkLabel.VisitedLinkColor屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET LinkLabel.VisitedLinkColor屬性的具體用法?VB.NET LinkLabel.VisitedLinkColor怎麽用?VB.NET LinkLabel.VisitedLinkColor使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在System.Windows.Forms.LinkLabel的用法示例。


在下文中一共展示了LinkLabel.VisitedLinkColor屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: Main

' 導入命名空間
Imports System.Drawing
Imports System.Windows.Forms

Public NotInheritable Class Form1
    Inherits System.Windows.Forms.Form

    Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel

    <System.STAThread()> _
    Public Shared Sub Main()
        System.Windows.Forms.Application.Run(New Form1)
    End Sub

    Public Sub New()
        MyBase.New()


        Me.LinkLabel1 = New System.Windows.Forms.LinkLabel

        ' Configure the LinkLabel's size and location. Specify that the
        ' size should be automatically determined by the content.
        Me.linkLabel1.Location = New System.Drawing.Point(34, 56) 
        Me.linkLabel1.Size = New System.Drawing.Size(224, 16) 
        Me.linkLabel1.AutoSize = True 

        ' Configure the appearance.
        ' Set the DisabledLinkColor so that a disabled link will show up against the form's background.
        Me.linkLabel1.DisabledLinkColor = System.Drawing.Color.Red 
        Me.linkLabel1.VisitedLinkColor = System.Drawing.Color.Blue 
        Me.linkLabel1.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline 
        Me.linkLabel1.LinkColor = System.Drawing.Color.Navy 
        
        Me.linkLabel1.TabIndex = 0 
        Me.linkLabel1.TabStop = True 
        
        ' Identify what the first Link is.
        Me.linkLabel1.LinkArea = New System.Windows.Forms.LinkArea(0, 8)

        ' Identify that the first link is visited already.
        Me.linkLabel1.Links(0).Visited = true
        
        ' Set the Text property to a string.
        Me.linkLabel1.Text = "Register Online.  Visit Microsoft.  Visit MSN."

        ' Create new links using the Add method of the LinkCollection class.
        ' Underline the appropriate words in the LinkLabel's Text property.
        ' The words 'Register', 'Microsoft', and 'MSN' will 
        ' all be underlined and behave as hyperlinks.

        ' First check that the Text property is long enough to accommodate
        ' the desired hyperlinked areas.  If it's not, don't add hyperlinks.
        If Me.LinkLabel1.Text.Length >= 45 Then
            Me.LinkLabel1.Links(0).LinkData = "Register"
            Me.LinkLabel1.Links.Add(24, 9, "www.microsoft.com")
            Me.LinkLabel1.Links.Add(42, 3, "www.msn.com")
            ' The second link is disabled and will appear as red.
            Me.linkLabel1.Links(1).Enabled = False
        End If

        ' Set up how the form should be displayed and adds the controls to the form.
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.LinkLabel1})
        Me.Text = "Link Label Example"
    End Sub

    Private Sub linkLabel1_LinkClicked(ByVal sender As Object, _
                ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked

        ' Determine which link was clicked within the LinkLabel.
        Me.LinkLabel1.Links(LinkLabel1.Links.IndexOf(e.Link)).Visited = True

        ' Displays the appropriate link based on the value of the LinkData property of the Link object.
        Dim target As String = CType(e.Link.LinkData, String)

        ' If the value looks like a URL, navigate to it.
        ' Otherwise, display it in a message box.
        If (target IsNot Nothing) AndAlso (target.StartsWith("www")) Then
            System.Diagnostics.Process.Start(target)
        Else
            MessageBox.Show(("Item clicked: " + target))
        End If

    End Sub

End Class
開發者ID:VB.NET開發者,項目名稱:System.Windows.Forms,代碼行數:86,代碼來源:LinkLabel.VisitedLinkColor

示例2: LinkLabelLinkData

' 導入命名空間
Imports System.Windows.Forms
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D

public class LinkLabelLinkData
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        LinkLabel1.Text = "Home Page is www.microsoft.com"
        LinkLabel1.Links.Add(13, 28, "http://www.microsoft.com")
        LinkLabel1.LinkArea = New LinkArea(13, 28)
        LinkLabel1.LinkColor = Color.Red
        LinkLabel1.VisitedLinkColor = Color.Aqua
        LinkLabel1.ActiveLinkColor = Color.Pink
        LinkLabel1.Links(0).LinkData = "Register"
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Label1.Text = LinkLabel1.Text
    End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.LinkLabel1 = New System.Windows.Forms.LinkLabel
        Me.Button1 = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'LinkLabel1
        '
        Me.LinkLabel1.AutoSize = True
        Me.LinkLabel1.Location = New System.Drawing.Point(182, 51)
        Me.LinkLabel1.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
        Me.LinkLabel1.Name = "LinkLabel1"
        Me.LinkLabel1.Size = New System.Drawing.Size(87, 15)
        Me.LinkLabel1.TabIndex = 0
        Me.LinkLabel1.TabStop = True
        Me.LinkLabel1.Text = "LinkLabel1"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(185, 181)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(139, 28)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Button1"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(64, 51)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(55, 15)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "Label1"
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(547, 250)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.LinkLabel1)
        Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label

End Class
開發者ID:VB程序員,項目名稱:System.Windows.Forms,代碼行數:106,代碼來源:LinkLabel.VisitedLinkColor


注:本文中的System.Windows.Forms.LinkLabel.VisitedLinkColor屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。