我想显示所有包含我在textbox5.text中输入的值的行。
当我输入一个月的例子是10进入textbox5然后点击button4我想搜索为具有示例10的BirthMonth的企业创建的文件然后在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
答案 0 :(得分:1)
答案 1 :(得分:0)