listview控件:怎么选中某一行的子项 如何实现:点击我想要的内容时(如某一行的子项),该子项变成选中状态。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你是指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); } } } }加个这个看看是不是你要的效果 求解一个算法 多层panel显示问题 判断EXCEL是否有该表 c#中一个谁都想知道的问题 2007-06-22T18:02:46.578125+08:00 这样的时间格式如何获得? 实现这个功能用什么控件好呢? 用remoting实现类似QQ聊天程序 winform GridControl自带打印怎么自适应纸张 progressbar的Marquee我设置了怎么没有用啊 購物車中的數據用什麼方式保存比較好? 关于发送邮件smtp中的奇怪问题 有关C#中两个数据类型转换的问题,请高手解决下。
{
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);
}
}
}
}加个这个看看是不是你要的效果