日期:2014-05-18  浏览次数:20559 次

请高手帮我看下这代码什么意思
protected void Button1_Click(object sender, EventArgs e)
  {
  int count = lbxSource.Items.Count;
  int index = 0;
  for (int i = 0; i < count; i++)
  {
  ListItem Item = lbxSource.Items[index];
  lbxSource.Items.Remove(Item);
  lbxDest.Items.Add(Item);
  }
  index++;
我在编的是Listbox控件的多选操作,lbxSource是Listbox控件的ID
int count = lbxSource.Items.Count;这句话的意思就是获取列表框的选项数,
那 int index = 0;这句代码是什么意思
ListItem Item = lbxSource.Items[index];这句代码又是什么意思
ListItem,这个是什么意思,有什么作用

------解决方案--------------------
int index = 0;
定义一个整形变量index,初值为0

ListItem Item = lbxSource.Items[index]; 
定义一个ListItem类Item,值为lbxSource.Items[index];即等于lbxSource第0项,界面上实际看到是第1项

ListItem 
类:命名空间,System.Web.UI.WebControls,一般表示列表控件中的数据项