CListCtrl的列标题 [英] Column headers of a CListCtrl

查看:148
本文介绍了CListCtrl的列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在选项卡控件内部使用带有CListCtrl的CTabCtrl,我需要知道在切换选项卡时如何删除列标题.我已经尝试过CListCtrl :: DeleteColumn(),但似乎没有效果.我也尝试过...

I''m using a CTabCtrl with a CListCtrl inside the tab control, I need to know how to remove the column headings when I switch tabs. I''ve tried CListCtrl::DeleteColumn() and it does not seem to have an effect. I have also tried...

int headCount = m_ListCtrl.GetHeaderCtrl()->GetItemCount();

for(int i = 0; i < headCount; i++)
{
    m_ListCtrl.GetHeaderCtrl()->DeleteItem(i);
}





Any suggestions?

推荐答案

您的上述代码将无法删除所有列,一半将始终保留:

假设您有3列

第0、1和2列

删除第0列,现在有第0列和第1列,其余的列将得到提升.
您删除第1列,现在只有第0列
您尝试删除第2列,但调用失败,因为第2列中没有该列
Your above code would fail to delete all the columns, half would always remain:

Say you had 3 columns

Columns 0, 1 and 2

you delete column 0, you now have columns 0, 1 as the remaining columns get promoted.
you delete column 1, you now have column 0 only
you attempt to delete column 2, but the call fails as there in no column 2

for(int i = 0; i < headCount; i++)
{
    m_ListCtrl.GetHeaderCtrl()->DeleteItem(0); // always delete column 0 only
}


您需要按照 ^ ].


这篇关于CListCtrl的列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆