如何清除wxListBox中的所有选择(使用wxLB_MULTIPLE)
How to clear all selections in a wxListBox (with wxLB_MULTIPLE)?
如何清除样式为wxLB_MULTIPLE
的wxListBox中的所有选择
wxControlWithItems::SetSelection()和wxControl WIthItems::SetStringSelection()都不起作用。他们只选择通过的项目,但没有像文件中所说的那样取消选择任何其他项目:
请注意,这不会导致发出任何命令事件,也不会它是否取消选择控件中支持的任何其他项多重选择。
我会使用wxListBox::GetSelections然后是wxListBox::取消选择,因为没有取消选择所有方法。
独立于平台的方法
正如StevenL所提到的,您必须在一个循环中使用wxListBox::GetSelections()
和wxListBox::Deselect()
:
wxArrayInt selections;
int count = m_listBox->GetSelections(selections);
for ( int i=0; i<count; i++ )
{
m_listBox->Deselect(selections[i]);
}
ListBox_SetSet宏(适用于Windows系统)
您可以使用Windows API中的宏ListBox_SetSet。
对于这个函数,您必须包括Windowsx.h
和wx/msw/winundef.h
,当然:
#include <Windowsx.h>
#include <wx/msw/winundef.h>
// ...
HWND hListBox = (HWND)m_listBox->GetHandle();
ListBox_SetSel(hListBox, false, -1);
m_listBox->清除();这种方法适用于我
相关文章:
- QT 样式表主题,适用于使用属性选择器的整个应用程序
- 线程和互斥锁的使用有什么问题
- 使用指针选择长无符号变量中的数字
- 有选择地禁用第三方库的C++核心准则检查器
- 有选择地禁用库中的死代码消除
- C++,有选择地应用模板模式来发挥作用
- 使用 SFINAE 有选择地实例化模板的成员函数
- 有选择地隐藏类成员的成员
- 使用dialog_fselect选择文件
- 使用模板选择正确的矢量
- 如何使用Qcombobox选择如何保存qimage的格式
- 模板化使用 无法选择要在 Visual Studio 中用作参数的模板函数
- 以一种方式使用字符串选择(如果语句)
- 为什么我要获得不同的输出?我使用有界的缓冲区,pthreads和Semaphores对C 进行编码
- 有选择地启用一个并行区域内的OpenMP进行循环
- 大小应该使用有符号整数还是无符号整数
- 有选择地对向量 c++ 进行排序
- 是否可以使用有条件选择的字符串文本初始化字符数组
- 我可以使用 SFINAE 有选择地定义模板类中的成员变量吗?
- 在Java中使用SWIG,我如何有选择地SWIG一个巨大的C/ c++头文件的某些部分