2011-05-23 34 views
0

我試圖在標籤中顯示輸出,並保留之前輸入的所有數據的記錄。也許在某種下拉菜單中?顯示標籤中的輸出

如何保存所有輸入的數據?

任何人都可以幫我嗎?

感謝,

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 

namespace DatabaseSQLApp 
{ 
    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void textBox1_TextChanged(object sender, EventArgs e) 
     { 

     } 

     private void btnStrings_Click(object sender, EventArgs e) 
     { 
      string firstName; 
      firstName = textBox1.Text; 
      MessageBox.Show(firstName); 

     } 

     private void label1_Click(object sender, EventArgs e) 
     { 


     } 
    } 
} 
+0

爲什麼不使用備忘錄呢? – Cynede 2011-05-23 17:51:07

回答

1

在btnStrings_Click,加入這一行:

label1.Text += Environment.NewLine+firstName; 

只要確保你讓足夠的空間標籤增長

0

如果我理解你想什麼要做的是,Label是使用錯誤的UI組件。從設計者的工具箱中,將ListBox拖放到您的應用程序中。從那裏你可以在你的btnStrings事件處理程序中做到這一點:

private void btnStrings_Click(object sender, EventArgs e) 
    { 
     listBox1.Items.Add(textBox1.Text); 
    } 
+0

甜,亞歷克斯!那正是我想要達到的目標。我很感激。現在 - 我的申請工作。 – 2011-05-23 19:18:08

+0

這段代碼看起來有點草率。我怎麼把所有這些放在一起,讓代碼看起來更好? - 'string ArtistName,SongTitle,Source,Url; ArtistName = textBox1.Text; SongTitle = textBox2.Text; Source = textBox3.Text; Url = textBox4.Text; Database.Items.Add(textBox1.Text + textBox2 + textBox3 + textBox4);' – 2011-05-23 19:20:31