switch 0 Report post Posted December 6, 2004 hi,im trying to add stuff to a listbox in a dialog called by my CDocument classie. CMyDocument::DoSomeStuff()[br]{[/br]CMyDialog dlg;[br]dlg.listbox.addString("whatever");[br][/br]********[br][/br]dlg.listbox.doModal();[/br]} do i need to add something at the ******* to refresh my listbox because at the moment it is appearing downright empty. i created it by making a dialog in the resource editor of vc++ .NET 2003 and then using add class wizard, and add member wizard to make the listbox an accessable control.thanks for your time! Share this post Link to post Share on other sites
LuciferStar 0 Report post Posted December 6, 2004 tryList->InsertItem (&item);List->InsertColumn (x,fd->name,LVCFMT_LEFT,strlen(fd->name)*6+16,1); [br][/br] List->DeleteAllItems( ); // 删除当前所有item[br][/br] res = mysql_store_result( myData );[br] for ( int x = 0; fd = mysql_fetch_field( res ); x++ )[/br] {[br] List->InsertColumn (x,fd->name,LVCFMT_LEFT,strlen(fd->name)*6+16,1);//获取column[/br] }[br] LV_ITEM item;[/br] item.mask = LVIF_TEXT;[br] item.iItem = -1;[/br] while ( row = mysql_fetch_row( res ) )[br] {[/br] j = mysql_num_fields( res );[br] item.iItem+=1;[/br] for (int k = 0; k < j; k++ )[br] {[/br] item.iSubItem = k;[br] item.pszText=row[k];[/br] List->InsertItem (&item);[br] List->SetItem (&item);[/br] }[br] }[/br] Share this post Link to post Share on other sites
switch 0 Report post Posted December 13, 2004 hmmmm.... thanks but i think that is for mysql....im using mfc in visual c++ .NET, so it isn't much of a help.thanks for your time anyway. Share this post Link to post Share on other sites
switch 0 Report post Posted December 18, 2004 hi again, i finally got stuff sorted out. I was after the mfc dialog UpdateData(FALSE) method after the CListBox.AddString() method but i was putting UpdateData(FALSE) in the Dialog's OnCreate() method. because the control wasn't created yet, the listbox control could not be refreshed (i think). thanks for your help! Share this post Link to post Share on other sites