Windows Develop Bookmark and Share   
 index > Windows Forms General > need to display multiplelines using messagebox
 

need to display multiplelines using messagebox

hi,

i need to diplay the text in multiplelines in messagebox.Help me with this.

thanks

venp

venp  Thursday, October 19, 2006 7:23 PM

Environment.NewLine or \r\n will work :-) Example:

MessageBox.Show("hello\r\nMy name is bob");

ahmedilyas  Thursday, October 19, 2006 7:24 PM

even though both solutions are valid (as always, replies are welcomed!) it is best to use the language's syntax instead of importing another language into the language you are using for many reasons, including this.

So which ever language you are using, use its functions/syntax than trying to import from another one....

ahmedilyas  Thursday, October 19, 2006 8:29 PM

Environment.NewLine or \r\n will work :-) Example:

MessageBox.Show("hello\r\nMy name is bob");

ahmedilyas  Thursday, October 19, 2006 7:24 PM

Hi

You can introduce line breaks within your message box using the line feed or carriage return characters as so:

MessageBox.Show("Line 1" & ControlChars.Lf & "Line 2" & ControlChars.Lf & "Line 3")

Is this what you meant?

 

HTH

Edit: Sorry for the cross post.

David Jeavons  Thursday, October 19, 2006 7:25 PM

Does this command work in c#.

I included microsoft.visualbasic but it doesnt work.

venp

venp  Thursday, October 19, 2006 7:32 PM
the initial response given works
ahmedilyas  Thursday, October 19, 2006 7:37 PM

sorry for the confusion.

I meant to ask David Jeavons about this command

MessageBox.Show("Line 1" & ControlChars.Lf & "Line 2" & ControlChars.Lf & "Line 3")

whether the above cmd works in c#.

ahmedilyas'c cmd is working. thanks

venp  Thursday, October 19, 2006 7:42 PM
well that is pretty much equiv to \r\n (line field) - \r\n is a carriage return I believe.
ahmedilyas  Thursday, October 19, 2006 7:52 PM

I'm not getting ControlChars in my intellisense..what i have to include for reference other than microsoft.visualbasic

venp

venp  Thursday, October 19, 2006 8:00 PM

HI

If you are using C# then you should go with the initial response given by ahmedilyas. I certainly wouldn't want to import the Microsoft.VisualBasic Namespace into a C# project unless I had a really good reason too, and this isn't one of them.

David Jeavons  Thursday, October 19, 2006 8:11 PM

Okay then, I'll proceed with ahmedilyas cmd.Thanks for me helping with this.

Thanks

venp

venp  Thursday, October 19, 2006 8:16 PM

even though both solutions are valid (as always, replies are welcomed!) it is best to use the language's syntax instead of importing another language into the language you are using for many reasons, including this.

So which ever language you are using, use its functions/syntax than trying to import from another one....

ahmedilyas  Thursday, October 19, 2006 8:29 PM

You can use google to search for other answers

Custom Search

More Threads

• Comparing Types
• window service
• Intercepting keydown "Delete"
• dispose exception with write back caching
• VB or C#, and why?
• consuming C++ API from .net
• How I can know any point COLOR on a form, if a form has gradient fill?
• Flickering effect
• ToolStripDropDown.IsAutoGenerated?
• Windows Form In Apache