Pop up a message with a URL.

  • Thread starter Thread starter Boki
  • Start date Start date
B

Boki

Hi All,

Could you advice how to:

1. Pop up a message, I remember it is called messagebox.show() in VB6.
How to do it in VC#?
2. I want add a URL inside the messagebox, is that doable? How ?

Thank you very much!

Best regards,
Boki.
 
Boki said:
Hi All,

Could you advice how to:

1. Pop up a message, I remember it is called messagebox.show() in VB6.
How to do it in VC#?
2. I want add a URL inside the messagebox, is that doable? How ?

Thank you very much!

Best regards,
Boki.

Hi Boki,
1. Pop up a message, I remember it is called messagebox.show() in VB6.
How to do it in VC#?

I remember it being 'MsgBox' in VB6. In C#, it *is* MessageBox.Show(...).
Make sure you import the System.Windows.Forms namespace.
2. I want add a URL inside the messagebox, is that doable? How ?
Are you talking about a clickable URL? If so, then not using the built-in
framework routines for message boxes. You'd have to create a custom
messagebox using a form (and use a LinkLabel?).
 
Hi,
Pop up a message, I remember it is called messagebox.show() in VB6.

1. This is pretty straight-forward: MessageBox.Show("Your
message...");
I want add a URL inside the messagebox, is that doable? How ?

2. This is a little more involved; you'll need to create a new form
and then add a LinkLabel to it.

3. Add a new Window Form called 'UrlMessageBox.cs'

4. Right-click on the new form and select "View Code"

5. Then replace the text below:

public UrlMessageBox()
{
InitializeComponent();
}

with the following text and save:

public UrlMessageBox()
{
InitializeComponent();
}

private void btnClose_Click(object sender, EventArgs e)
{
Close();
}

private void lnklblCodingHelp_LinkClicked(object sender,
LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://coding-
help.blogspot.com/");
}


5. You can view a complete sample here:

http://rasikaw.googlepages.com/UrlMessageBox.cs

6. In Solution Explorer click on the '+' sign infornt of
'UrlMessageBox.cs' to view its designer file called
'UrlMessageBox.Designer.cs'.

7. Open 'UrlMessageBox.Designer.cs'

8. Replace the text below:

#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.components = new System.ComponentModel.Container();
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.Text = "UrlMessageBox";
}

#endregion

with the following text and save:

#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.lblText = new System.Windows.Forms.Label();
this.lnklblCodingHelp = new
System.Windows.Forms.LinkLabel();
this.btnClose = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblText
//
this.lblText.AutoSize = true;
this.lblText.Location = new System.Drawing.Point(12, 9);
this.lblText.Name = "lblText";
this.lblText.Size = new System.Drawing.Size(293, 13);
this.lblText.TabIndex = 0;
this.lblText.Text = "Hello this is my custom message box.
Click on the link below:";
//
// lnklblCodingHelp
//
this.lnklblCodingHelp.AutoSize = true;
this.lnklblCodingHelp.Location = new
System.Drawing.Point(12, 32);
this.lnklblCodingHelp.Name = "lnklblCodingHelp";
this.lnklblCodingHelp.Size = new System.Drawing.Size(164,
13);
this.lnklblCodingHelp.TabIndex = 1;
this.lnklblCodingHelp.TabStop = true;
this.lnklblCodingHelp.Text = "http://coding-
help.blogspot.com/";
this.lnklblCodingHelp.LinkClicked += new
System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnklblCodingHelp_LinkClicked);
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(126,
66);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 2;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new
System.EventHandler(this.btnClose_Click);
//
// UrlMessageBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F,
13F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(325, 111);
this.ControlBox = false;
this.Controls.Add(this.btnClose);
this.Controls.Add(this.lnklblCodingHelp);
this.Controls.Add(this.lblText);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "UrlMessageBox";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "Url Message Box";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label lblText;
private System.Windows.Forms.LinkLabel lnklblCodingHelp;
private System.Windows.Forms.Button btnClose;

8a. You can view a complete sample here:

http://rasikaw.googlepages.com/UrlMessageBox.Designer.cs

9. In Solution Explorer right click on the main / parent form (e.g.
Form1.cs) that you want to lauch this form from and select 'View
Designer'

10. Add a button to it called 'btnLaunch'.

11. Double click on this button so that it creates a event handler as
shown below:

private void btnLaunch_Click(object sender, EventArgs e)
{

}

12. Add the following code to it so that it looks like this:

private void btnLaunch_Click(object sender, EventArgs e)
{
UrlMessageBox urlMsgBox = new UrlMessageBox();
urlMsgBox.ShowDialog();
}

12a. You can view a complete sample here:

http://rasikaw.googlepages.com/Form1.cs

13. That's it!

14 You can also download the project that I created for the code above
from here:

http://rasikaw.googlepages.com/UrlMessageBox.zip

RKW
http://coding-help.blogspot.com/
 
Hi,


1. This is pretty straight-forward: MessageBox.Show("Your
message...");


2. This is a little more involved; you'll need to create a new form
and then add a LinkLabel to it.

3. Add a new Window Form called 'UrlMessageBox.cs'

4. Right-click on the new form and select "View Code"

5. Then replace the text below:

public UrlMessageBox()
{
InitializeComponent();
}

with the following text and save:

public UrlMessageBox()
{
InitializeComponent();
}

private void btnClose_Click(object sender, EventArgs e)
{
Close();
}

private void lnklblCodingHelp_LinkClicked(object sender,
LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://coding-
help.blogspot.com/");
}

5. You can view a complete sample here:

http://rasikaw.googlepages.com/UrlMessageBox.cs

6. In Solution Explorer click on the '+' sign infornt of
'UrlMessageBox.cs' to view its designer file called
'UrlMessageBox.Designer.cs'.

7. Open 'UrlMessageBox.Designer.cs'

8. Replace the text below:

#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.components = new System.ComponentModel.Container();
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.Text = "UrlMessageBox";
}

#endregion

with the following text and save:

#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.lblText = new System.Windows.Forms.Label();
this.lnklblCodingHelp = new
System.Windows.Forms.LinkLabel();
this.btnClose = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblText
//
this.lblText.AutoSize = true;
this.lblText.Location = new System.Drawing.Point(12, 9);
this.lblText.Name = "lblText";
this.lblText.Size = new System.Drawing.Size(293, 13);
this.lblText.TabIndex = 0;
this.lblText.Text = "Hello this is my custom message box.
Click on the link below:";
//
// lnklblCodingHelp
//
this.lnklblCodingHelp.AutoSize = true;
this.lnklblCodingHelp.Location = new
System.Drawing.Point(12, 32);
this.lnklblCodingHelp.Name = "lnklblCodingHelp";
this.lnklblCodingHelp.Size = new System.Drawing.Size(164,
13);
this.lnklblCodingHelp.TabIndex = 1;
this.lnklblCodingHelp.TabStop = true;
this.lnklblCodingHelp.Text = "http://coding-
help.blogspot.com/";
this.lnklblCodingHelp.LinkClicked += new
System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnklblCodingHelp_LinkClicked);
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(126,
66);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 2;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new
System.EventHandler(this.btnClose_Click);
//
// UrlMessageBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F,
13F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(325, 111);
this.ControlBox = false;
this.Controls.Add(this.btnClose);
this.Controls.Add(this.lnklblCodingHelp);
this.Controls.Add(this.lblText);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "UrlMessageBox";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "Url Message Box";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label lblText;
private System.Windows.Forms.LinkLabel lnklblCodingHelp;
private System.Windows.Forms.Button btnClose;

8a. You can view a complete sample here:

http://rasikaw.googlepages.com/UrlMessageBox.Designer.cs

9. In Solution Explorer right click on the main / parent form (e.g.
Form1.cs) that you want to lauch this form from and select 'View
Designer'

10. Add a button to it called 'btnLaunch'.

11. Double click on this button so that it creates a event handler as
shown below:

private void btnLaunch_Click(object sender, EventArgs e)
{

}

12. Add the following code to it so that it looks like this:

private void btnLaunch_Click(object sender, EventArgs e)
{
UrlMessageBox urlMsgBox = new UrlMessageBox();
urlMsgBox.ShowDialog();
}

12a. You can view a complete sample here:

http://rasikaw.googlepages.com/Form1.cs

13. That's it!

14 You can also download the project that I created for the code above
from here:

http://rasikaw.googlepages.com/UrlMessageBox.zip

RKWhttp://coding-help.blogspot.com/

It works fine, thank you!

Boki.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top