comboBox如何获取(新建文本文档)每行的数据?
------解决方案--------------------------------------------------------
streamreader去readline,然后将readline的内容添加到combox的items
------解决方案--------------------------------------------------------
按行读文本放到comboBox里
System.IO.StreamReader sr = new System.IO.StreamReader("c:\\A.txt", System.Text.Encoding.Default);
string strLine = sr.ReadLine();
while (strLine != null)
{
comboBox.Items.Add(strLine);
strLine = sr.ReadLine();
}
sr.Close();
------解决方案--------------------------------------------------------
File.ReadAllLines("D:\\1.txt", Encoding.Default).ToList().ForEach(t => comboBox1.Items.Add(t));
if (comboBox1.Items.Count > 0)
comboBox1.SelectedIndex = 0;