private void PaintListView()
{
//创建标题,属性设置为不显示
********
try
{
FileStream aFile = new FileStream(filename, FileMode.Open);
StreamReader sr = new StreamReader(aFile, System.Text.Encoding.GetEncoding("gb2312")); string strLine; //逐行文本变量
********
listView1.BeginUpdate(); for (int i = 0; sr.Peek() > -1; i++)
{
strLine = sr.ReadLine();********
}
listView1.EndUpdate(); sr.Close();
}
catch
{
}
}
在这个方法中,产生一个变量是我需要用于下一个方法中的
private void listViewExG_SelectedIndexChanged(object sender, EventArgs e)
{
}我想请问下,如果不在PaintListView()的外面,也就是这个Form1类里添加一个公共变量,如何让方法PaintListView内部的变量给另一个listViewExG_SelectedIndexChanged方法调用呢?我试着在PaintListView()里添加public,但是没有出现public的关键字提示,说明不管用,确实,我强制写完
public int Val1;
就提示invalid expression term public错误了
{
//创建标题,属性设置为不显示
********
try
{
FileStream aFile = new FileStream(filename, FileMode.Open);
StreamReader sr = new StreamReader(aFile, System.Text.Encoding.GetEncoding("gb2312")); string strLine; //逐行文本变量
********
listView1.BeginUpdate(); for (int i = 0; sr.Peek() > -1; i++)
{
strLine = sr.ReadLine();********
}
listView1.EndUpdate(); sr.Close();
}
catch
{
}
}
在这个方法中,产生一个变量是我需要用于下一个方法中的
private void listViewExG_SelectedIndexChanged(object sender, EventArgs e)
{
}我想请问下,如果不在PaintListView()的外面,也就是这个Form1类里添加一个公共变量,如何让方法PaintListView内部的变量给另一个listViewExG_SelectedIndexChanged方法调用呢?我试着在PaintListView()里添加public,但是没有出现public的关键字提示,说明不管用,确实,我强制写完
public int Val1;
就提示invalid expression term public错误了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货