毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> net技术 >> 正文

listview如何选中某行的子项

更新时间:2012-5-16:  来源:毕业论文

如何实现:点击我想要的内容时(如某一行的子项),该子项变成选中状态。

你是指SubItem?单个选中?

是啊,有办法么?
private void listView1_MouseUp(object sender, MouseEventArgs e)
  {
  ListView _ListView = (ListView)sender;
  ListViewItem _Item = _ListView.GetItemAt(5, e.Y);  

  if (_Item != null)
  {
  ListViewItem.ListViewSubItem _SubItem = _Item.GetSubItemAt(e.X, 5);  

  if (_SubItem != null) 
  {
  Control _SetLabel = _ListView.Controls["SelectLab"];
  if (_SetLabel == null)
  {
  _SetLabel = new Label();
  _SetLabel.Name = "SelectLab";
  _SetLabel.AutoSize = false;
  _SetLabel.BackColor = Color.Yellow;
  _SetLabel.ForeColor = Color.Red;
  _SetLabel.Font = _ListView.Font;
  _ListView.Controls.Add(_SetLabel);
  }
  _SetLabel.Text = _SubItem.Text;
  _SetLabel.Location = new Point(_SubItem.Bounds.X, _SubItem.Bounds.Y);
  if (_SubItem.Equals(_Item.SubItems[0]))
  {
  _SetLabel.Size = new Size(_ListView.Columns[0].Width, _SubItem.Bounds.Height);  
  }
  else
  {  
  _SetLabel.Size = new Size(_SubItem.Bounds.Width, _SubItem.Bounds.Height);  
  }  }  }  }

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。