2011-05-23 106 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