禁用CListCtrl排序 [英] Disable CListCtrl sorting
问题描述
如何关闭CListCtrl
排序?
我派生了CListCtrl
和CHeaderCtrl
,在新列表控件类的PreSubclassWindow()
中,我做了类似以下操作来禁用列表排序.
Hi,
How can I turn off CListCtrl
sorting??
I derived CListCtrl
and CHeaderCtrl
, in PreSubclassWindow()
of new list control class i did something like following to disable list sorting.
if(GetHeaderCtrl())
{
m_headerCtrl.SubclassWindow(GetHeaderCtrl()->m_hWnd);
m_headerCtrl.ModifyStyle(HDS_BUTTONS, 0);
}
我确实将资源文件中列表控件的排序属性设置为无",并将视图类型设置为报告".但是,当我按特定顺序使用LV_ITEM
结构将项目插入列表时,项目将重新排序.
I did set sort property of list control in resource file to "None" and view type to "Report". But when I insert item into list using LV_ITEM
struct in my specific order, items are re-sorted.
Did i miss something here in order to disable list control''s sorting?
推荐答案
我不确定,但是以下代码可能会有所帮助:-
I am not sure but may be the following code will help: -
CHeaderCtrl* pHeader = GetListCtrl().GetHeaderCtrl();
if( pHeader!=NULL)
{
pHeader->ModifyStyle(HDS_BUTTONS, 0); // disable the sorting.
}
希望这可以帮助.让我知道它是否有效
-
AJ
Hope this helps. Let me know if it worked
--
AJ
我知道了.在我的OnInitDialog()函数中,我有
I figured it out. In my OnInitDialog() function, i have
DWORD dwStyle = m_lstCtrl.GetExtendedStyle();
dwStyle |= LVS_EX_FULLROWSELECT;
m_lstCtrl.ModifyStyle(0, dwStyle | LVS_REPORT);
通过注释掉这些行并应用ankitjoshi24的解决方案,可以解决此问题.
但我仍然不明白为什么这些行会引起问题?
Quy
By commenting out these lines and applying ankitjoshi24''s solution,the problem is solved.
But still I dont understand why these lines caused the problem??
Quy
这篇关于禁用CListCtrl排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!