Windows窗体程序中:using(StreamReader ts = new StreamReader(odlgTextFile.OpenFile()))
{
listBox1.Text = ts.ReadToEnd();
textBox1.Text = odlgTextFile.FileName;
}“textBox1.Text = odlgTextFile.FileName;”能很好执行,但是“listBox1.Text = ts.ReadToEnd();”似乎没起作用,ListBox中仍然没有内容。请问是怎么回事?
{
listBox1.Text = ts.ReadToEnd();
textBox1.Text = odlgTextFile.FileName;
}“textBox1.Text = odlgTextFile.FileName;”能很好执行,但是“listBox1.Text = ts.ReadToEnd();”似乎没起作用,ListBox中仍然没有内容。请问是怎么回事?
错误 1 “System.Windows.Forms.ListBox”并不包含“Item”的定义 E:\Backup\我的文档\Visual Studio 2005\Projects\CH3_DemoForm010\Form1.cs 44 50 CH3_DemoForm010
listBox1.Item.Add(ss);
错误 1 “System.Windows.Forms.ListBox”并不包含“Item”的定义 E:\Backup\我的文档\Visual Studio 2005\Projects\CH3_DemoForm010\Form1.cs 46 50 CH3_DemoForm010
是ITEMS,被楼上的带过去了!
那肯定没有listbox列表控件中没有数据
要想在列表控件里添加数据,必须有items
属性
下面的代码是正解
using(StreamReader ts = new StreamReader(odlgTextFile.OpenFile()))
{
string st= ts.ReadToEnd();
listBox1.Items.Add(st);
textBox1.Text = odlgTextFile.FileName;
}
reanline
一行一行的读取,然后一行一行的添加到listbox中
我的没这个问题啊