2

I'm creating LinkLabel in Form2 and Form3 with the same code. Form2 and Form3 are separate classes so the names don't interferer. They are both created, but in the Form 3 links open, in the Form2 nothing happens.

This is the code for Form2

public partial class Form2 : Form
{
  public void createFormEntry(List<string> videoId)
  {
    LinkLabel link = new LinkLabel();
    link.Name = "link";
    link.AutoSize = true;
    link.Location = new Point(76, 8);
    link.Text = "www.example.com";
    link.LinkClicked += new LinkLabelLinkClickedEventHandler(link_LinkClicked);
    this.Controls.Add(link);
  }   

    private void link_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {
        System.Diagnostics.Process.Start("http://www.example.com");
    }
}

And this is for the Form3

public partial class Form3 : Form
{
  private void createFormEntry(Feed<Video> videoFeed)
  {
    LinkLabel link = new LinkLabel();
    link.Name = "link";
    link.AutoSize = true;
    link.Location = new Point(76, 8);
    link.Text = "www.example.com";
    link.LinkClicked += new LinkLabelLinkClickedEventHandler(link_LinkClicked);
    this.Controls.Add(link);
  }

    private void link_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {
        System.Diagnostics.Process.Start("http://www.example.com");
    }
}

They are in different classes. Form2 opens before Form3. What could be wrong?

EDIT: now when I added more code, I see in Form2 createFormEntry is public and in Form3 it is set as private. Could that be a reason?

cikatomo
  • 1,620
  • 2
  • 23
  • 32
  • When link_LinkClicked is declared in Form3 as private void, how can you access it in Form2? Do you have some other code? – Link Dec 16 '12 at 23:24
  • Hi, I edited code, I hope now it's more clear – cikatomo Dec 16 '12 at 23:59
  • Just start your debugger and look where the problem is. I can't find anything in your code snippet. Maybe the important location is somewhere else. Maybe you are using an foreach(AtomEntry in videoFeed) and there are no AtomEntries. – Link Dec 17 '12 at 07:08

1 Answers1

0

Your trying to open a link without telling the program how or what to open that link in. You should tell it to search it in a program or something!