在添加足够的行以启用垂直滚动条之前,ClistBox不会显示 [英] ClistBox doesn't display until enough lines are added to enable the vertical scroll bar

查看:102
本文介绍了在添加足够的行以启用垂直滚动条之前,ClistBox不会显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,可以在列表框中添加行,以便用户可以看到发生的事情.但是,该框消失",仅显示水平滚动条,直到添加了足够的行,从而启用了垂直滚动条.到那时,所有添加的行都会显示出来.我尝试设置最高索引以查看是否可以使事情进展,并且确实有所帮助.实际上,最上面的索引的设置根本没有显示任何内容.在此之前,显示区域将消失",直到添加了所有行,然后全部显示.此外,SetTopIndex似乎不起作用.例如,如果我将最高索引设置为8,我希望添加的第九个字符串成为框中显示的第一行.但是,我设置的索引和要显示的行之间似乎没有任何关系.而是,该框保持满.这是可以接受的,因为用户可以看到最新添加的行,但这肯定不是我要的.

如果将"DisableNoScroll"设置为true,则该框不会消失".它只是简单地坐在那里空着,直到盒子得到的线条超出了它的容纳能力为止,然后垂直滚动条与所有等待显示的线条一起出现.

I have an application that adds lines to a list box so that the user can see what is happening as it happens. However, the box "disappears" with only the horizontal scroll bar displayed until enough lines have been added such that the vertical scroll bar gets enabled. At that time all of the added lines then get displayed. I have tried setting the top index to see if that would get things moving and it did help a little. Actually, it was the setting of the top index that got anything displayed at all. Previous to that, the display area would "disappear" until all of the lines had been added and then they would all be displayed. Furthermore, SetTopIndex doesn''t seem to work. For instance, if I set the top index to 8, I would expect the ninth string that I have added to be the first displayed line in the box. However, there doesn''t seem to be any relation between the index I set and the line that gets displayed. Instead, the box remains full. This is acceptable since the user is able to see the latest line added but it certainly isn''t what I am asking for.

If "DisableNoScroll" is set to true then the box does not "disappear". It simply sits there empty until the box gets one line more than it can hold and then the vertical scroll bar appears along with all of the lines that have been waiting to be displayed.

推荐答案

在Windows中重画的优先级较低...因此,如果在紧密循环中添加许多项目,将得到与您一样的结果.

滚动条出现时发生逆风的原因与列表区域大小更改的事实有关.我几乎可以确定,如果始终显示滚动条,其效果将类似于没有滚动条.

如果列表非常大,则最好在可能的情况下使用控件的虚拟模式.

否则,您始终可以强制更新列表框,并且可以修改代码以处理Windows消息或使用多个线程,以使UI线程不会100%的时间处于忙碌状态.

最佳解决方案取决于很多项目,无论您是否要自动滚动以及列表填充的速度.

通常,您必须在加载速度和UI的响应能力之间找到折衷方案.

同样,如果您一次添加很多项目(禁用更新)然后刷新所有内容,例如每隔一秒钟,它可能会更好.
Redrawing in Windows is low priority... Thus if you add a lot of items in a tight loop, you will get a result like you have.

The reason why a redrawind occurs when the scrollbar appears is related to the fact the list area size change. I''m almost sure that if the scroll bar were always displayed, it would have an effect similar to having none.

If you have really large list, you are better using virtual mode of the control if possible.

Otherwise, you can always force the list box to be updated and you can mofify your code to process windows message or uses multiple thread so that the UI thread is not 100% of the time busy.

Best solution depends a lot of the quantities of items, if you want auto-scroll or not and the speed at which the list is filled.

Typically you have to find a compromise between the loading speed and the responsiveness of the UI.

Also it might perform better if you add a lot of items at once (with updating disabled) and then refresh everything... for example every fraction of a second.


在另一个答案上检查此答案(类似)问题.如果您没有在UI和生成文本的事物上使用单独的线程,这可能会有所帮助.

更新列表框可视化c ++ [
Check this answer to another (similar) question. If you are not using separate threads for the UI and the thing that generates the text, this might help.

update listbox visual c++[^]


这篇关于在添加足够的行以启用垂直滚动条之前,ClistBox不会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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