Like Alni says, you can use AddString to add something to a listbox whenever
you'd like. You may have t refresh the control window. Also, you can use
DeleteString to remove a string. One problem with list boxes is that they
don't automatically update the width so if you add a new item that is wider
than the list is you don't automatically get a horizontal scroll bar. You
can address this by checking each item as it is added and adjusting the
extent for the listbox.
Something like:
int oldwidth = m_ListBox->GetHorizontalExtent();
CDC* pDC = m_ListBox->GetWindowDC();
if (pDC) {
int newwidth = pDC->GetTextExtent((const char*)csStringImAdding,
csStringImAdding.GetLength()).cx;
m_ListBox->ReleaseDC(pDC);
if (newwidth > oldwidth) {
m_ListBox->SetHorizontalExtent(newwidth);
}
}
Joe Newcomer has more info on his website about this stuff:
http://www.flounder.com/hscroll.htm
All of that said, I mostly use ListCtrl's these days for even one line
lists. There is way more control and they are not difficult to use.
Tom
Post by Mujtabahi
i am woking with ListBox control in VC++, where i have to update the
data in listbox control gradually,means some is added to listbox,
after some time next text added to list box and so on.
could anybody plz help me out.
Mujtaba