首页 > 题库 > 学历提升 > 自学考试 > 自考本科 > 填空题

在Form1窗体中有一个名称为oFD1的打开文件对话框,一个名称为textBox1的文本框和一个名称为button1的命令按钮。将下列事件程序补充完整,使得程序运行后,单击button1按钮,则显示打开文件对话框,操作者从中选择一个文本文件,并单击对话框中的“打开”按钮,则可打开该文本文件,并读入一行文本,显示在textBox1文本框中。
private void button1_Click(object sender, EventArgs e)
{

oFD1.FileName = " ",,
oFD1.Filter = "*.txt|* .xt"; 
if (oFD___________ () == DialogResult.OK) // (1)

{
string line;
StreamReader sr = new StreamReader(oFD1._______ true); // (2)
if (line = sr._________ ()) != null)  // (3)
textBox1.Text = line;
else
textBox1.Text= "文件为空! ";
sr.Close();
}

}


参考答案: 查看答案 查看解析 下载APP畅快刷题

相关知识点试题

相关试卷