我的输入代码如下:
class Input
{
public void Input_back(ListView listView1)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.ShowDialog();
string MyFileName = openFileDialog1.FileName;
if (MyFileName.Trim() == "")
return;
StreamReader myReader = null;
try
{ myReader = new StreamReader(MyFileName, System.Text.Encoding.Default);
string[] item = { "教辅用地21","体育场地2","仪器设备3","教师数量4","计算机数5","图书册6","班级7"};
for (int i = 0; i < 7; i++)
{
string[] temp1 = myReader.ReadLine().Split('\n', ',');
ListViewItem lvi = new ListViewItem(item[i], i);
for (int j = 0; j < 7; j++)
{
string[] temp2 = temp1[i].Split(' ');
lvi.SubItems.Add(temp2[j]);
}
listView1.Items.Add(lvi);
}
}
class Input
{
public void Input_back(ListView listView1)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.ShowDialog();
string MyFileName = openFileDialog1.FileName;
if (MyFileName.Trim() == "")
return;
StreamReader myReader = null;
try
{ myReader = new StreamReader(MyFileName, System.Text.Encoding.Default);
string[] item = { "教辅用地21","体育场地2","仪器设备3","教师数量4","计算机数5","图书册6","班级7"};
for (int i = 0; i < 7; i++)
{
string[] temp1 = myReader.ReadLine().Split('\n', ',');
ListViewItem lvi = new ListViewItem(item[i], i);
for (int j = 0; j < 7; j++)
{
string[] temp2 = temp1[i].Split(' ');
lvi.SubItems.Add(temp2[j]);
}
listView1.Items.Add(lvi);
}
}
