OykunYenal
OykunYenal

Reputation: 85

How to use Hyperlink property in Windows form Application C#

I need to help about this issue, I have code inside asp.net page like;

for (int i = 0; i < lbl; i++)
    {
        HyperLink lnkBtn = new HyperLink();
        lnkBtn.CssClass = "btn";
        lnkBtn.Text = "WEB PAGE NAME";
        lnkBtn.NavigateUrl = "URL OF DESİRED PAGES";
        lnkBtn.Target = "myFrame";
        LiteralControl linebreak = new LiteralControl("<br />");
        placeholder.Controls.Add(lnkBtn);
        placeholder.Controls.Add(linebreak);
    }

I'm adding the hyperlink as button to the webpage, datas coming from database. I want to do the same thing windows form application.

I found "linklabel" but I need to target it to the browser on the application. I used webkitbrowser to display pages.

Any suggestion ?

Upvotes: 2

Views: 3233

Answers (3)

dkackman
dkackman

Reputation: 15569

Handle the LinkClicked event in your WinForms code and perform whatever custom navigation from there. Your handler would look something like this (assuming browser is some sort of browser control also on the Form and the Tag property of the link held the full Uri of the target)

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
    browser.Navigate(e.Link.Tag.ToString());
}

Upvotes: 2

Alexey Obukhov
Alexey Obukhov

Reputation: 854

Link button is just a button styled as link. Put LinkButton component on form, open events and search for click event, double click on it. In generated method write:

System.Diagnostics.Process.Start("http://www.website.com");

Upvotes: 1

rdn87
rdn87

Reputation: 724

You can:

  • add in your Form WebBrowser control
  • add new button
  • add in your button_click() the logic for open a site in WebBrowser

Upvotes: 1

Related Questions