Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
public void InitializeComponent()
       {
           this.listBox1 = new System.Windows.Forms.ListBox();
           this.button1 = new System.Windows.Forms.Button();
           this.textBox1 = new System.Windows.Forms.TextBox();
           this.SuspendLayout();
           //
           // listBox1
           //
           this.listBox1.FormattingEnabled = true;
           this.listBox1.Items.AddRange(new object[] {
           "1",
           "2",
           "3",
           "4",
           "5",
           "6"});
           this.listBox1.Location = new System.Drawing.Point(70, 31);
           this.listBox1.Name = "listBox1";
           this.listBox1.Size = new System.Drawing.Size(120, 95);
           this.listBox1.TabIndex = 0;


I Want Add Item to ListBox Without Saving Just Save in form.Designer.cs foe example I add 6 Item to listBox Manualy via Collection Now I Want Add another Item from TextBox. HOW I CAN DO IT
Posted
Updated 25-Feb-11 2:31am
v2

Do you mean this?
string strText = textbox1.Text;
listBox1.Items.Add(strText);
 
Share this answer
 
Comments
Espen Harlinn 25-Feb-11 8:46am    
It's obviously a solution :)
Richard MacCutchan 25-Feb-11 9:10am    
More of a question really, as I am not sure what the problem is.
Espen Harlinn 25-Feb-11 9:22am    
He could always add a button and place your code inside an event handler ... that would be a fairly obvious solution
Richard MacCutchan 25-Feb-11 13:15pm    
I do get the feeling with some of these questions that some people are creating applications one question at a time without any real understanding of the basics of the language they are working with.
first of all thank you for your attention ;)
No
I want to Store Items In listBox Whitout saving in DataBase or etc
and Keep data after rerun the Program
My mean change the Source Of the program fo ever
 
Share this answer
 
In short, that is the wrong approach.
You would have to get the program to re-compile itself after a change which is not practical.
One approach is to look at serialization or simply read from and write to a multi line text file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900