Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Mfc Dialog Trouble, involving listboxes
switch
post Dec 6 2004, 07:09 AM
Post #1


Premium Member
********

Group: Members
Posts: 178
Joined: 13-October 04
From: NSW, Australia
Member No.: 1,713



hi,

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

ie.

CODE
CMyDocument::DoSomeStuff()
{
CMyDialog dlg;
dlg.listbox.addString("whatever");

********

dlg.listbox.doModal();
}


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!
Go to the top of the page
 
+Quote Post
LuciferStar
post Dec 6 2004, 11:01 AM
Post #2


Advanced Member
*******

Group: Members
Posts: 114
Joined: 9-August 04
From: Suzhou Jiangsu China
Member No.: 743



try
List->InsertItem (&item);
List->InsertColumn (x,fd->name,LVCFMT_LEFT,strlen(fd->name)*6+16,1);

CODE


  List->DeleteAllItems( ); // 删除当前所有item

  res = mysql_store_result( myData );
  for ( int x = 0; fd = mysql_fetch_field( res ); x++ )
  {
   List->InsertColumn (x,fd->name,LVCFMT_LEFT,strlen(fd->name)*6+16,1);//获取column
  }
  LV_ITEM    item;
  item.mask = LVIF_TEXT;
  item.iItem = -1;
  while ( row = mysql_fetch_row( res ) )
  {
   j = mysql_num_fields( res );
   item.iItem+=1;
   for (int k = 0; k < j; k++ )
   {
    item.iSubItem = k;
    item.pszText=row[k];
    List->InsertItem (&item);
    List->SetItem (&item);
   }
  }
Go to the top of the page
 
+Quote Post
switch
post Dec 13 2004, 05:58 AM
Post #3


Premium Member
********

Group: Members
Posts: 178
Joined: 13-October 04
From: NSW, Australia
Member No.: 1,713



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.
Go to the top of the page
 
+Quote Post
switch
post Dec 18 2004, 05:29 AM
Post #4


Premium Member
********

Group: Members
Posts: 178
Joined: 13-October 04
From: NSW, Australia
Member No.: 1,713



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!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Win32: Dialog Box And Accelerator(1)


 



- Lo-Fi Version Time is now: 5th September 2008 - 08:30 AM