循环不会更新列表框,直到它完成迭代 [英] Loop doesn't update listboxes until it is done iterating
本文介绍了循环不会更新列表框,直到它完成迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个循环,从列表框中获取文件名,执行一个system()调用,然后将该文件名移动到另一个列表框。问题是,它不会一次移动文件名一个,但等待,直到整个循环完成,并一次移动它们。
I have a loop that takes file name from a listbox, performs a system() call, then moves that filename to another listbox. Problem is, it doesn't move the filenames over one at a time, but waits until the entire loop is finished and moves them all at once. What would I do to get it to perform how I want it to?
循环:
for each( String^% file in filename )
{
int x = convert( file );
lbComplete->Items->Add( lbFiles->Items[0] ); // place the completed file
lbFiles->Items->Remove( lbFiles->Items[0] ); // in the other listbox
}
包含系统调用的convert :
The function convert() that contains the system call:
int convert( String^ file )
{
std::stringstream ss;
std::string dir, fileAddress, fileName, outputDir;
...
return system( ss.str().c_str() );
}
推荐答案
刷新函数在循环结束时强制它重绘你的列表框,否则它会等待循环之后这样做。
You would need to call a refresh function at the end of your loop forcing it to redraw your listboxes otherwise it will wait until after your loop to do so.
for each( String^% file in filename )
{
int x = convert( file );
lbComplete->Items->Add( lbFiles->Items[0] ); // place the completed file
lbFiles->Items->Remove( lbFiles->Items[0] ); // in the other listbox
// INSERT REFRESH FUNCTION HERE
}
这篇关于循环不会更新列表框,直到它完成迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文