473,320 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help with LinkLabel

Community,

I am very new to using C# and to programming, period.

I am using visual studio's windows application. I am trying to have the application open up displaying two links. When each link is clicked, I would like for them to open up their own respective windows, whether they be window apps like the forms, or IE windows. I was trying to use the LinkLabels to do this. any help is appreciated.

Thanks,

Noob
May 31 '07 #1
8 1453
mwalts
38
Community,

I am very new to using C# and to programming, period.

I am using visual studio's windows application. I am trying to have the application open up displaying two links. When each link is clicked, I would like for them to open up their own respective windows, whether they be window apps like the forms, or IE windows. I was trying to use the LinkLabels to do this. any help is appreciated.

Thanks,

Noob
Ok, your going to want to add this statement near the top (with the other using statments)

using System.Diagnostics;

now in your link Labels on click event you want to add something like this

Process pIE = new Process();

pIE.StartInfo.FileName = "http://TheLink.html";
pIE.StartInfo.UseShellExecute = true;

pIE.Start();


And that should do it

Heh, I just realized my variable name was pie, delicious pie :p

Have fun,

-mwalts
May 31 '07 #2
Thank you very much. The code worked great, but that works for external sites. Now the problem that i'm encoutering is that i've composed two HTML pages that use a combination of both HTML and Javascript. These pages are saved as .html files on my computer, and I moved them into the folder with the .cs file that I made in Visual Studio hoping that it'd find these .html files and open them. How do I get the code provided to open up these files that i've made?



Ok, your going to want to add this statement near the top (with the other using statments)

using System.Diagnostics;

now in your link Labels on click event you want to add something like this

Process pIE = new Process();

pIE.StartInfo.FileName = "http://TheLink.html";
pIE.StartInfo.UseShellExecute = true;

pIE.Start();


And that should do it

Heh, I just realized my variable name was pie, delicious pie :p

Have fun,

-mwalts
May 31 '07 #3
NEVERMIND!!!

That is no longer my problem. I remembered that all I have to do is simulate a certain scenario, so that is not an issue anymore. I'm sure i'll have another issue very shortly. :-D
May 31 '07 #4
OK. The problem that I am having now is that when I click on both links, they are refreshing in the SAME window. I need the links to open up their own individual windows. I renamed the second process to pIE2 along with the two .startinfo statements and the one .start statement, but that's not making it open into a new window. any suggestions??



NEVERMIND!!!

That is no longer my problem. I remembered that all I have to do is simulate a certain scenario, so that is not an issue anymore. I'm sure i'll have another issue very shortly. :-D
May 31 '07 #5
mwalts
38
OK. The problem that I am having now is that when I click on both links, they are refreshing in the SAME window. I need the links to open up their own individual windows. I renamed the second process to pIE2 along with the two .startinfo statements and the one .start statement, but that's not making it open into a new window. any suggestions??
Hmm, doesn't happen in Internet explorer 7, it will open in a new tab.

Can I see the exact code your using?

But it could be that IE recognizes that it is already open and just changes sites instead, in which case, you might have to actually automate IE

http://www.novicksoftware.com/TipsAndTricks/tip-csharp-open-ie-browser.htm

-mwalts
May 31 '07 #6
all of my code is as follows:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;


namespace Problem1Solution

{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.LinkLabel linkLabel2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.linkLabel2 = new System.Windows.Forms.LinkLabel();
((System.ComponentModel.ISupportInitialize)(this.d ataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(144, 408);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dat aGrid1_Navigate);
//
// linkLabel1
//
this.linkLabel1.ActiveLinkColor = System.Drawing.Color.RoyalBlue;
this.linkLabel1.Location = new System.Drawing.Point(16, 16);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(128, 24);
this.linkLabel1.TabIndex = 1;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "Document Flow";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHand ler(this.linkLabel1_LinkClicked);
//
// linkLabel2
//
this.linkLabel2.ActiveLinkColor = System.Drawing.Color.RoyalBlue;
this.linkLabel2.Location = new System.Drawing.Point(16, 48);
this.linkLabel2.Name = "linkLabel2";
this.linkLabel2.Size = new System.Drawing.Size(128, 24);
this.linkLabel2.TabIndex = 2;
this.linkLabel2.TabStop = true;
this.linkLabel2.Text = "Document Flow";
this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHand ler(this.linkLabel2_LinkClicked);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(536, 437);
this.Controls.Add(this.linkLabel2);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.d ataGrid1)).EndInit();
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void dataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{



}
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
Process pIE = new Process();

pIE.StartInfo.FileName = "http://www.google.com";
pIE.StartInfo.UseShellExecute = true;

pIE.Start();

}

private void linkLabel2_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
Process pIE2 = new Process();

pIE2.StartInfo.FileName = "http://www.yahoo.com";
pIE2.StartInfo.UseShellExecute = true;

pIE2.Start();

}
}
}









Hmm, doesn't happen in Internet explorer 7, it will open in a new tab.

Can I see the exact code your using?

But it could be that IE recognizes that it is already open and just changes sites instead, in which case, you might have to actually automate IE

http://www.novicksoftware.com/TipsAndTricks/tip-csharp-open-ie-browser.htm

-mwalts
Jun 1 '07 #7
mwalts
38
all of my code is as follows:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;


namespace Problem1Solution

{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.LinkLabel linkLabel2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.linkLabel2 = new System.Windows.Forms.LinkLabel();
((System.ComponentModel.ISupportInitialize)(this.d ataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(144, 408);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dat aGrid1_Navigate);
//
// linkLabel1
//
this.linkLabel1.ActiveLinkColor = System.Drawing.Color.RoyalBlue;
this.linkLabel1.Location = new System.Drawing.Point(16, 16);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(128, 24);
this.linkLabel1.TabIndex = 1;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "Document Flow";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHand ler(this.linkLabel1_LinkClicked);
//
// linkLabel2
//
this.linkLabel2.ActiveLinkColor = System.Drawing.Color.RoyalBlue;
this.linkLabel2.Location = new System.Drawing.Point(16, 48);
this.linkLabel2.Name = "linkLabel2";
this.linkLabel2.Size = new System.Drawing.Size(128, 24);
this.linkLabel2.TabIndex = 2;
this.linkLabel2.TabStop = true;
this.linkLabel2.Text = "Document Flow";
this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHand ler(this.linkLabel2_LinkClicked);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(536, 437);
this.Controls.Add(this.linkLabel2);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.d ataGrid1)).EndInit();
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void dataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{



}
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
Process pIE = new Process();

pIE.StartInfo.FileName = "http://www.google.com";
pIE.StartInfo.UseShellExecute = true;

pIE.Start();

}

private void linkLabel2_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
Process pIE2 = new Process();

pIE2.StartInfo.FileName = "http://www.yahoo.com";
pIE2.StartInfo.UseShellExecute = true;

pIE2.Start();

}
}
}
yeah, that should have done it.

I don't have the old version of IE anymore so I can't reproduce it.

Looks like you're stuck with automation.

Or, if you know for sure where IE is, you can do something like this

pIE.FileName = @"""C:\Program Files\Internet Explorer\iexplore.exe""";
pIE.Arguments = "-new www.google.com";
pIE.Start();

but if you are running it on more then one computer, and IE is in a different place (unlikely I'll grant) then it will break.

-mwalts
Jun 1 '07 #8
wow. I thank you for your help and dedication to aiding me with resolving this problem. Your help has been GREATLY appreciated. I will either attempt to do it with the method that you provided, or just deal with it.

Thank You VERY much,

CsharpNOOB


yeah, that should have done it.

I don't have the old version of IE anymore so I can't reproduce it.

Looks like you're stuck with automation.

Or, if you know for sure where IE is, you can do something like this

pIE.FileName = @"""C:\Program Files\Internet Explorer\iexplore.exe""";
pIE.Arguments = "-new www.google.com";
pIE.Start();

but if you are running it on more then one computer, and IE is in a different place (unlikely I'll grant) then it will break.

-mwalts
Jun 1 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: tota | last post by:
i'm using windowsApplication to connect to DB made by SQL i need to Display the Data of the first table in the DB as links when click it it openes a table and i navigte between them using buttons...
3
by: vince | last post by:
Hello, I have a ListBox filled with many lines of simply text I want to make few lines be a LinkLabel How can I do this Thanks
1
by: Marcus Kwok | last post by:
I am having problems getting my LinkLabel hyperlink to work properly. Every time I click on it, I get the following exception: System.ComponentModel.Win32Exception: The requested lookup key was...
4
by: David Veeneman | last post by:
I'm creating a UserControl that uses a LinkLabel. For reasons that I won't bore everyone with, I don't want the LinkLable to show the default hand cursor when the mouse enters the control. Should...
3
by: bsturg21 | last post by:
Hello, I have a windows form that has a series of linklabels on it, and I need to have each linklabel, when clicked, open a separate windows form that has a single paramter passed into it. The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.