我希望它顯示包含我在textbox5.text中輸入的所有值的所有行。顯示內容的問題
當我輸入一個月的例子是10到textbox5,然後單擊button4我想搜索爲具有示例10的BirthMonth的enteries創建的文件,然後在label7中顯示結果。
public void writetext()
{
using (TextWriter writer = File.AppendText("filename.txt"))
{
writer.WriteLine("First name, {0} Lastname, {1} Phone,{2} Day of birth,{3} Month of Birth{4}", textBox1.Text, textBox2.Text, maskedTextBox1.Text, textBox4.Text, textBox3.Text);
MessageBox.Show(String.Format("First Name,{0} Lastname, {1} Phone,{2} Day of birth,{3} Month of Birth{4}", textBox1.Text, textBox2.Text, maskedTextBox1.Text, textBox4.Text, textBox3.Text));
}
}
public void reset()
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
maskedTextBox1.Text = "";
}
private void button4_Click(object sender, EventArgs e)
{
string[] lines = File.ReadAllLines("filename.txt");
try{
int month = Int32.Parse(textBox5.Text);
label7.Text = String.Format("Month of Birth {0}", lines[month]);
}
catch(Exception){
label7.Text = "Invalid input";
}
}
public void readfile()
{
string[] lines = File.ReadAllLines("filename.txt");
label6.Text = String.Join(Environment.NewLine, lines);
}
First name, 99999 Lastname, 87t8t8 Phone,999-9999 Day of birth,ug Month of Birthoi
First name, 9898988 Lastname, 787877 Phone,999-9999 Day of birth,67 Month of Birth78
First name, Lastname, Phone,588-8888 Day of birth, Month of Birth
First name, ytyt Lastname, Phone, - Day of birth, Month of Birth
First name, iuiu Lastname, Phone, - Day of birth, Month of Birth
First name, 98989 Lastname, Phone, - Day of birth, Month of Birth
First name, plplpl Lastname, Phone, - Day of birth, Month of Birth
First name, okok Lastname, uihuhuh Phone,777-7777 Day of birth,54 Month of Birth76
First name, 090909 Lastname, Phone, - Day of birth, Month of Birth
First name, ijijij Lastname, Phone, - Day of birth, Month of Birth
First name, kjkj Lastname, Phone, - Day of birth, Month of Birth
First name, Lastname, Phone, - Day of birth, Month of Birth
First name, Lastname, Phone, - Day of birth, Month of Birth
First name, ygyg Lastname, Phone, - Day of birth, Month of Birth
我敢打賭,你可以是一個小更明確你想完成什麼!我幾乎可以猜到! – 2010-11-11 02:36:10
我試圖解釋它好一點。但是當我在textbox5中輸入一個數字時,我想要它,然後單擊按鈕4我想搜索爲所有輸入數字創建的文件,這些輸入數字已經輸入到textbox5中以顯示在標籤中7 – user770022 2010-11-11 02:41:18