Jump to content
xisto Community
switch

Mfc Dialog Trouble involving listboxes

Recommended Posts

hi,

im trying to add stuff to a listbox in a dialog called by my CDocument class

ie.

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

try
List->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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.