15,979
社区成员
发帖
与我相关
我的任务
分享
不选择时也能删除, 说明默认选择了第一项了.
看看你初始化时是不是选中了第一条 实在不行就在初始化的时候 m_list.SetCurSel(-1);
又见一个滥用 NULL 的。虽然说 NULL 在 C++ 里等于 0,但 GetCurSel 很明显返回的是整数值。MSDN 上也说过了,像 ComboBox 和 ListBox 的错误值都是 -1,而 0 表示第一个项。
[quote=引用 8 楼 ztzi321 的回复:] [quote=引用 7 楼 ztzi321 的回复:] [quote=引用 5 楼 zhuyf87 的回复:] 改一下:int curSel = m_list.GetCurSel(); if (LB_ERR == curSel) MessageBox("你删除为空,请选择所要删除的内容!!"); else m_list.DeleteString(curSel);
[quote=引用 7 楼 ztzi321 的回复:] [quote=引用 5 楼 zhuyf87 的回复:] 改一下:int curSel = m_list.GetCurSel(); if (LB_ERR == curSel) MessageBox("你删除为空,请选择所要删除的内容!!"); else m_list.DeleteString(curSel);
[quote=引用 5 楼 zhuyf87 的回复:] 改一下:int curSel = m_list.GetCurSel(); if (LB_ERR == curSel) MessageBox("你删除为空,请选择所要删除的内容!!"); else m_list.DeleteString(curSel);
[quote=引用 5 楼 zhuyf87 的回复:] 改一下:int curSel = m_list.GetCurSel(); if (LB_ERR == curSel) MessageBox("你删除为空,请选择所要删除的内容!!"); else m_list.DeleteString(curSel);
改一下:int curSel = m_list.GetCurSel(); if (LB_ERR == curSel) MessageBox("你删除为空,请选择所要删除的内容!!"); else m_list.DeleteString(curSel);
int curSel = m_list.GetCurSel();
if (LB_ERR == curSel)
MessageBox("你删除为空,请选择所要删除的内容!!");
else
m_list.DeleteString(curSel);
[quote=引用 1 楼 zhuyf87 的回复:] 第一行肯定能删的吧。只不过删掉了第一行之后,后面的会补到第一行。 deleting the first item will cause the remaining item to now be in the first position. nIndex=0 for the item in the first position.
第一行肯定能删的吧。只不过删掉了第一行之后,后面的会补到第一行。
deleting the first item will cause the remaining item to now be in the first position. nIndex=0 for the item in the first position.