CComboBox control variable 
Author Message
 CComboBox control variable

Hello All,

I'm hoping you can help me out with this craziness:

The code for populating a ComboBox is simple. However,
it's difficult to actually populate the combo box when the
control variable isn't recognized by your code. In
the "OnInitialUpdate" function I try to populate the
ComboBox.  Here are the experpts that you need to get the
idea from both the DatabaseView header and source files:

..h file:

   public:
   //{{AFX_DATA(CDatabaseView)
   enum { IDD = IDD_AESBASE_FORM };
   CComboBox    m_cClient;
   CComboBox    m_cVendor;
   CDatabaseSet* m_pSet;
   CString      m_sQkSchFirst;
   CString      m_sQkSchLast;
   CString      m_sQkSchPONo;
   CString      m_sQkSchQuoteNo;
   CString      m_sTemp;
   //}}AFX_DATA

..cpp file:

..
..
..
void CAESBaseView::DoDataExchange(CDataExchange* pDX)
{
   CDatabaseView::DoDataExchange(pDX);
   //{{AFX_DATA_MAP(CAESBaseView)
   DDX_Control(pDX, IDC_SELECTCLIENT, m_cClient);
   DDX_Control(pDX, IDC_SELECTVENDOR, m_cVendor);
   DDX_Text(pDX, IDC_QKSCHCLIENTFIRST, m_sQkSchFirst);
   DDX_Text(pDX, IDC_QKSCHCLIENTLAST, m_sQkSchLast);
   DDX_Text(pDX, IDC_QKSCHPONO, m_sQkSchPONo);
   DDX_Text(pDX, IDC_QKSCHQUOTENO, m_sQkSchQuoteNo);
   //}}AFX_DATA_MAP

Quote:
}

..
..
..
void CDatabaseView::OnInitialUpdate()
{
   m_pSet = &GetDocument()->m_aDatabaseSet;
   CRecordView::OnInitialUpdate();
   GetParentFrame()->RecalcLayout();
   ResizeParentToFit();

   CString TempClient , TempVendor ;

   for( int i = 0 ; i < m_pSet->GetRecordCount( ) ; i++ )
   {
      TempClient = m_pSet->m_Client_Company_Name ;
      m_pSet->MoveNext( ) ;

      m_cClient.AddString( TempClient ) ;
   }

Quote:
}

As you can see from the code, the CComboBox control
variable is declared in the header file and the source
file.  I created them with the ClassWizard. For some
reason, in this line:

      m_cClient.AddString( TempClient ) ;

the "m_cClient" variable doesn't respond to the data that
I send to it. It compiles, but at run-time there is no
data in the ComboBox. There are records in the database
for it to pull and populate the box with, but nothing
shows up.

Any help here would be hot.

Thank you in advance!
Eric



Sat, 31 Jan 2004 01:43:09 GMT  
 CComboBox control variable
Everything looks right. You will forgive me for asking the obvious but
are you sure your database call is returning some data? i.e. is there
something in TempClient? Does the de{*filter*} show data?
Quote:

> Hello All,

> I'm hoping you can help me out with this craziness:

> The code for populating a ComboBox is simple. However,
> it's difficult to actually populate the combo box when the
> control variable isn't recognized by your code. In
> the "OnInitialUpdate" function I try to populate the
> ComboBox.  Here are the experpts that you need to get the
> idea from both the DatabaseView header and source files:

> ..h file:

>    public:
>    //{{AFX_DATA(CDatabaseView)
>    enum { IDD = IDD_AESBASE_FORM };
>    CComboBox    m_cClient;
>    CComboBox    m_cVendor;
>    CDatabaseSet* m_pSet;
>    CString      m_sQkSchFirst;
>    CString      m_sQkSchLast;
>    CString      m_sQkSchPONo;
>    CString      m_sQkSchQuoteNo;
>    CString      m_sTemp;
>    //}}AFX_DATA

> ..cpp file:

> ..
> ..
> ..
> void CAESBaseView::DoDataExchange(CDataExchange* pDX)
> {
>    CDatabaseView::DoDataExchange(pDX);
>    //{{AFX_DATA_MAP(CAESBaseView)
>    DDX_Control(pDX, IDC_SELECTCLIENT, m_cClient);
>    DDX_Control(pDX, IDC_SELECTVENDOR, m_cVendor);
>    DDX_Text(pDX, IDC_QKSCHCLIENTFIRST, m_sQkSchFirst);
>    DDX_Text(pDX, IDC_QKSCHCLIENTLAST, m_sQkSchLast);
>    DDX_Text(pDX, IDC_QKSCHPONO, m_sQkSchPONo);
>    DDX_Text(pDX, IDC_QKSCHQUOTENO, m_sQkSchQuoteNo);
>    //}}AFX_DATA_MAP
> }
> ..
> ..
> ..
> void CDatabaseView::OnInitialUpdate()
> {
>    m_pSet = &GetDocument()->m_aDatabaseSet;
>    CRecordView::OnInitialUpdate();
>    GetParentFrame()->RecalcLayout();
>    ResizeParentToFit();

>    CString TempClient , TempVendor ;

>    for( int i = 0 ; i < m_pSet->GetRecordCount( ) ; i++ )
>    {
>       TempClient = m_pSet->m_Client_Company_Name ;
>       m_pSet->MoveNext( ) ;

>       m_cClient.AddString( TempClient ) ;
>    }
> }

> As you can see from the code, the CComboBox control
> variable is declared in the header file and the source
> file.  I created them with the ClassWizard. For some
> reason, in this line:

>       m_cClient.AddString( TempClient ) ;

> the "m_cClient" variable doesn't respond to the data that
> I send to it. It compiles, but at run-time there is no
> data in the ComboBox. There are records in the database
> for it to pull and populate the box with, but nothing
> shows up.

> Any help here would be hot.

> Thank you in advance!
> Eric



Sat, 31 Jan 2004 03:09:35 GMT  
 CComboBox control variable
Thanks for the response Tahir!  It's funny, in between the
time where I posted the thread and you responded, I
narrowed it down to the very thing you're asking about.
The database is open, but it returns no data for some
reason. Any insight?

Thank you,
Eric

Quote:
>-----Original Message-----
>Everything looks right. You will forgive me for asking
the obvious but
>are you sure your database call is returning some data?
i.e. is there
>something in TempClient? Does the de{*filter*} show data?


>> Hello All,

>> I'm hoping you can help me out with this craziness:

>> The code for populating a ComboBox is simple. However,
>> it's difficult to actually populate the combo box when
the
>> control variable isn't recognized by your code. In
>> the "OnInitialUpdate" function I try to populate the
>> ComboBox.  Here are the experpts that you need to get
the
>> idea from both the DatabaseView header and source files:

>> ..h file:

>>    public:
>>    //{{AFX_DATA(CDatabaseView)
>>    enum { IDD = IDD_AESBASE_FORM };
>>    CComboBox    m_cClient;
>>    CComboBox    m_cVendor;
>>    CDatabaseSet* m_pSet;
>>    CString      m_sQkSchFirst;
>>    CString      m_sQkSchLast;
>>    CString      m_sQkSchPONo;
>>    CString      m_sQkSchQuoteNo;
>>    CString      m_sTemp;
>>    //}}AFX_DATA

>> ..cpp file:

>> ..
>> ..
>> ..
>> void CAESBaseView::DoDataExchange(CDataExchange* pDX)
>> {
>>    CDatabaseView::DoDataExchange(pDX);
>>    //{{AFX_DATA_MAP(CAESBaseView)
>>    DDX_Control(pDX, IDC_SELECTCLIENT, m_cClient);
>>    DDX_Control(pDX, IDC_SELECTVENDOR, m_cVendor);
>>    DDX_Text(pDX, IDC_QKSCHCLIENTFIRST, m_sQkSchFirst);
>>    DDX_Text(pDX, IDC_QKSCHCLIENTLAST, m_sQkSchLast);
>>    DDX_Text(pDX, IDC_QKSCHPONO, m_sQkSchPONo);
>>    DDX_Text(pDX, IDC_QKSCHQUOTENO, m_sQkSchQuoteNo);
>>    //}}AFX_DATA_MAP
>> }
>> ..
>> ..
>> ..
>> void CDatabaseView::OnInitialUpdate()
>> {
>>    m_pSet = &GetDocument()->m_aDatabaseSet;
>>    CRecordView::OnInitialUpdate();
>>    GetParentFrame()->RecalcLayout();
>>    ResizeParentToFit();

>>    CString TempClient , TempVendor ;

>>    for( int i = 0 ; i < m_pSet->GetRecordCount( ) ;
i++ )
>>    {
>>       TempClient = m_pSet->m_Client_Company_Name ;
>>       m_pSet->MoveNext( ) ;

>>       m_cClient.AddString( TempClient ) ;
>>    }
>> }

>> As you can see from the code, the CComboBox control
>> variable is declared in the header file and the source
>> file.  I created them with the ClassWizard. For some
>> reason, in this line:

>>       m_cClient.AddString( TempClient ) ;

>> the "m_cClient" variable doesn't respond to the data
that
>> I send to it. It compiles, but at run-time there is no
>> data in the ComboBox. There are records in the database
>> for it to pull and populate the box with, but nothing
>> shows up.

>> Any help here would be hot.

>> Thank you in advance!
>> Eric

>.



Sat, 31 Jan 2004 03:45:55 GMT  
 CComboBox control variable
Can't really tell without looking at more code. Are you sure the
database isn't raising some error that you're not catching?
Quote:

> Thanks for the response Tahir!  It's funny, in between the
> time where I posted the thread and you responded, I
> narrowed it down to the very thing you're asking about.
> The database is open, but it returns no data for some
> reason. Any insight?

> Thank you,
> Eric

> >-----Original Message-----
> >Everything looks right. You will forgive me for asking
> the obvious but
> >are you sure your database call is returning some data?
> i.e. is there
> >something in TempClient? Does the de{*filter*} show data?


> >> Hello All,

> >> I'm hoping you can help me out with this craziness:

> >> The code for populating a ComboBox is simple. However,
> >> it's difficult to actually populate the combo box when
> the
> >> control variable isn't recognized by your code. In
> >> the "OnInitialUpdate" function I try to populate the
> >> ComboBox.  Here are the experpts that you need to get
> the
> >> idea from both the DatabaseView header and source files:

> >> ..h file:

> >>    public:
> >>    //{{AFX_DATA(CDatabaseView)
> >>    enum { IDD = IDD_AESBASE_FORM };
> >>    CComboBox    m_cClient;
> >>    CComboBox    m_cVendor;
> >>    CDatabaseSet* m_pSet;
> >>    CString      m_sQkSchFirst;
> >>    CString      m_sQkSchLast;
> >>    CString      m_sQkSchPONo;
> >>    CString      m_sQkSchQuoteNo;
> >>    CString      m_sTemp;
> >>    //}}AFX_DATA

> >> ..cpp file:

> >> ..
> >> ..
> >> ..
> >> void CAESBaseView::DoDataExchange(CDataExchange* pDX)
> >> {
> >>    CDatabaseView::DoDataExchange(pDX);
> >>    //{{AFX_DATA_MAP(CAESBaseView)
> >>    DDX_Control(pDX, IDC_SELECTCLIENT, m_cClient);
> >>    DDX_Control(pDX, IDC_SELECTVENDOR, m_cVendor);
> >>    DDX_Text(pDX, IDC_QKSCHCLIENTFIRST, m_sQkSchFirst);
> >>    DDX_Text(pDX, IDC_QKSCHCLIENTLAST, m_sQkSchLast);
> >>    DDX_Text(pDX, IDC_QKSCHPONO, m_sQkSchPONo);
> >>    DDX_Text(pDX, IDC_QKSCHQUOTENO, m_sQkSchQuoteNo);
> >>    //}}AFX_DATA_MAP
> >> }
> >> ..
> >> ..
> >> ..
> >> void CDatabaseView::OnInitialUpdate()
> >> {
> >>    m_pSet = &GetDocument()->m_aDatabaseSet;
> >>    CRecordView::OnInitialUpdate();
> >>    GetParentFrame()->RecalcLayout();
> >>    ResizeParentToFit();

> >>    CString TempClient , TempVendor ;

> >>    for( int i = 0 ; i < m_pSet->GetRecordCount( ) ;
> i++ )
> >>    {
> >>       TempClient = m_pSet->m_Client_Company_Name ;
> >>       m_pSet->MoveNext( ) ;

> >>       m_cClient.AddString( TempClient ) ;
> >>    }
> >> }

> >> As you can see from the code, the CComboBox control
> >> variable is declared in the header file and the source
> >> file.  I created them with the ClassWizard. For some
> >> reason, in this line:

> >>       m_cClient.AddString( TempClient ) ;

> >> the "m_cClient" variable doesn't respond to the data
> that
> >> I send to it. It compiles, but at run-time there is no
> >> data in the ComboBox. There are records in the database
> >> for it to pull and populate the box with, but nothing
> >> shows up.

> >> Any help here would be hot.

> >> Thank you in advance!
> >> Eric

> >.



Sat, 31 Jan 2004 04:04:55 GMT  
 CComboBox control variable

This is not a reply, but an additional comment.

I also get this problem, but at a simpler level.  If I
create a Combo through the Dialog Editor, which claims to
alow entry of items directly, they don't come up.  THe
program compiles, yet the combo is empty.  Adding items
using code also doen't work.  Yet sometimes if I delete
and recreate this item, it works perfectly.  This sounds
like a bug to me, and if anybody knows a work around, I
need to know.

Ben

Quote:
>-----Original Message-----
>Hello All,

>I'm hoping you can help me out with this craziness:

>The code for populating a ComboBox is simple. However,
>it's difficult to actually populate the combo box when
the
>control variable isn't recognized by your code. In
>the "OnInitialUpdate" function I try to populate the
>ComboBox.  Here are the experpts that you need to get the
>idea from both the DatabaseView header and source files:

>...h file:

>   public:
>   //{{AFX_DATA(CDatabaseView)
>   enum { IDD = IDD_AESBASE_FORM };
>   CComboBox        m_cClient;
>   CComboBox        m_cVendor;
>   CDatabaseSet* m_pSet;
>   CString  m_sQkSchFirst;
>   CString  m_sQkSchLast;
>   CString  m_sQkSchPONo;
>   CString  m_sQkSchQuoteNo;
>   CString  m_sTemp;
>   //}}AFX_DATA

>...cpp file:

>...
>...
>...
>void CAESBaseView::DoDataExchange(CDataExchange* pDX)
>{
>   CDatabaseView::DoDataExchange(pDX);
>   //{{AFX_DATA_MAP(CAESBaseView)
>   DDX_Control(pDX, IDC_SELECTCLIENT, m_cClient);
>   DDX_Control(pDX, IDC_SELECTVENDOR, m_cVendor);
>   DDX_Text(pDX, IDC_QKSCHCLIENTFIRST, m_sQkSchFirst);
>   DDX_Text(pDX, IDC_QKSCHCLIENTLAST, m_sQkSchLast);
>   DDX_Text(pDX, IDC_QKSCHPONO, m_sQkSchPONo);
>   DDX_Text(pDX, IDC_QKSCHQUOTENO, m_sQkSchQuoteNo);
>   //}}AFX_DATA_MAP
>}
>...
>...
>...
>void CDatabaseView::OnInitialUpdate()
>{
>   m_pSet = &GetDocument()->m_aDatabaseSet;
>   CRecordView::OnInitialUpdate();
>   GetParentFrame()->RecalcLayout();
>   ResizeParentToFit();

>   CString TempClient , TempVendor ;

>   for( int i = 0 ; i < m_pSet->GetRecordCount( ) ; i++ )
>   {
>      TempClient = m_pSet->m_Client_Company_Name ;
>      m_pSet->MoveNext( ) ;

>      m_cClient.AddString( TempClient ) ;
>   }
>}

>As you can see from the code, the CComboBox control
>variable is declared in the header file and the source
>file.  I created them with the ClassWizard. For some
>reason, in this line:

>      m_cClient.AddString( TempClient ) ;

>the "m_cClient" variable doesn't respond to the data that
>I send to it. It compiles, but at run-time there is no
>data in the ComboBox. There are records in the database
>for it to pull and populate the box with, but nothing
>shows up.

>Any help here would be hot.

>Thank you in advance!
>Eric
>.



Sat, 21 Feb 2004 17:56:54 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Add Variable fails for control variables

2. Add Variable fails for control variables

3. limit of CComboBox and handling of scrolling event in a CComboBox

4. Redraw a control without an associated control variable ?

5. CComboBox 'Sort'ing Under Program Control?

6. CComboBox control

7. CComboBox control question

8. CEdit style in a CComboBox control

9. Setting the size of the drop down for a CComboBox control

10. OnChar() w/ CComboBox controls

11. Program Freezes when using CComboBox Control with Property Page

12. Subclassing edit-control of CComboBox

 

 
Powered by phpBB® Forum Software