C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

Windows Application C#


Posted Date: 29 Nov 2008      Posted By: Sachin Arora      Member Level: Silver     Points: 1   Responses: 2




listBox1 in Form1 & listBox2 in Form2 is added during the designer phase in the following code:



private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string str = "Credit Card Amout: 300";
str += "\r\n Moile Recharge: 20";
str += "\r\n Electricity ill: 25";
Form2 f2 = new Form2();
f2.listBox2.Items.Add(str);
f2.Show();
}



listBox2 is not showing the string values in different lines(due to \n)Why..

Also tell me the significance of \r(Carriage return) escape seq...





Responses

Author: Pavani    29 Nov 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 5

Hi

f2.listBox2.Items.Add(str);
As far as I know, though you are taking \n in the string variable str, still you are adding it to the list box as a single item. So, I think, it will not display the items as list. Instead try using "AddRange".

And as everyone knows, "\n" is for new line and "\r" is for carriage return, means it moves the cursor to the first character position of the new line.

Hope this is helpful for you...



Author: bob    01 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 3

ArrayList values = new ArrayList();

values.Add ("IN");
values.Add ("KS");
values.Add ("MD");
values.Add ("MI");
values.Add ("OR");
values.Add ("TN");

ListBox1.DataSource = values;
ListBox1.DataBind();



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : how to transfer data from datagridview to excel sheet in windows application using C#?
Previous : How to get name of web form in asp.net
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use