C# ListView总是有一个被选中
来源:互联网 发布:js二级联动菜单原理 编辑:程序博客网 时间:2024/04/28 20:43
int nLast = -1;
int nCur = -1;
private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
// 保留当期那被选择的状态
bSel = e.IsSelected;
var ll = listView1.SelectedIndices;
var asd = listView1.CheckedIndices;
// 将上一个设置为未选中
if (e.IsSelected)
{
nCur = e.ItemIndex;
if (nLast < 0)
{
nLast = e.ItemIndex;
}
}
else
{
nLast = e.ItemIndex;
}
if (e.IsSelected)
{
listView1.Items[e.ItemIndex].BackColor = SystemColors.Highlight;
listView1.Items[nLast].BackColor = SystemColors.Window;
}
if (bClickEmpty)
{
listView1.Items[nLast].BackColor = SystemColors.Highlight;
bClickEmpty = false;
nCur = nLast;
}
}
int xPos, yPos;
bool bClickEmpty = false;
private void listView1_MouseMove(object sender, MouseEventArgs e)
{
xPos = e.X;
yPos = e.Y;
}
private void listView1_MouseDown(object sender, MouseEventArgs e)
{
if (listView1.HitTest(xPos, yPos).Item == null) //点击空白处
{
bClickEmpty = true;
}
}
int nCur = -1;
private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
// 保留当期那被选择的状态
bSel = e.IsSelected;
var ll = listView1.SelectedIndices;
var asd = listView1.CheckedIndices;
// 将上一个设置为未选中
if (e.IsSelected)
{
nCur = e.ItemIndex;
if (nLast < 0)
{
nLast = e.ItemIndex;
}
}
else
{
nLast = e.ItemIndex;
}
if (e.IsSelected)
{
listView1.Items[e.ItemIndex].BackColor = SystemColors.Highlight;
listView1.Items[nLast].BackColor = SystemColors.Window;
}
if (bClickEmpty)
{
listView1.Items[nLast].BackColor = SystemColors.Highlight;
bClickEmpty = false;
nCur = nLast;
}
}
int xPos, yPos;
bool bClickEmpty = false;
private void listView1_MouseMove(object sender, MouseEventArgs e)
{
xPos = e.X;
yPos = e.Y;
}
private void listView1_MouseDown(object sender, MouseEventArgs e)
{
if (listView1.HitTest(xPos, yPos).Item == null) //点击空白处
{
bClickEmpty = true;
}
}
0 0
- C# ListView总是有一个被选中
- C# ListView选中行事件
- ListView中实现互斥按钮(每个Item中有两个button,永远只有一个item中的一个按钮被选中)
- Listview里嵌套radiobutton,默认只有一个可以被选中
- listView中有checkBox选中错乱问题解决
- ListView 里面的checkBox,当其中一个被选中,其余全不被选中
- 用JS判断CheckBox至少有一个被选中
- javascript 检查表单中的checkbox至少有一个被选中
- 判断是否至少有一个复选框被选中
- C# ListView 选中状态的判断方法
- c# listview取当前选中的值
- ListView选中selectedItem上下移动 C#
- Listview 取选中的值 C#
- C# ListView上下移动选中行
- c# 获取listview 选中行某列的值
- c#之listview获得选中行
- 笔记56--listview之selector、listview中同一时刻只有一个item能被选中
- Android listview中嵌套有gridview图片数据总是重复
- MFC多线程的创建,包括工作线程和用户界面线程
- sqlserver性能性能调优实战学习总结一
- Python :左旋转字符串
- 基于user 版本pac 定制kernel 内核
- jmeter下载安装以及插件安装(一)
- C# ListView总是有一个被选中
- soj->题号:1631:-------------一个字符串倒序输出 -------的水题
- C++ 带默认值的形参
- QGIS专题制图及输出
- bzoj4804: 欧拉心算
- jquery实现查看大图功能
- SpringMVC 使用@ResponseBody返回json 中文乱码
- 未来,什么样的程序员才是不可替代的?
- 如何下载Jason2测高数据