Home > Software engineering >  Questions about the MFC combobox
Questions about the MFC combobox

Time:10-23

MFC to create a window, the window there is a button and the combobox, click on the button will open the file, select a file, and then, according to edit box in the combobox and cannot be added to the combobox dropdown box, as shown in figure a drop-down box does not display the

CodePudding user response:

Increase the size combobox dropdown width height direction

CodePudding user response:

Is not like that, I want to through the button to open the folder dialog box, select a file, the file name is added to the inside of the combobox edit box without adding to the drop-down box!

CodePudding user response:

M_combo. SetWindowText (choose);//to the combo of edit

CodePudding user response:

The great god, can you write a specific//combo to edit

CodePudding user response:

M_combo. SetWindowText (),

CodePudding user response:

 CFileDialog DLG (TRUE, ""," ", NULL, ""); 
If (DLG) DoModal ()==IDOK)
{
Cstrings STR=DLG. GetPathName ();

CComboBox * comb=(CComboBox *) GetDlgItem (IDC_COMBO1);
Comb - & gt; AddString (_T (STR));
Int count=comb - & gt; GetCount ();
Comb - & gt; SetCurSel (count - 1);
}

I write so, m_combo SetWindowText () plus, it's no use the

CodePudding user response:

Your m_combo. SetWindowText () of the code is written in the book?

CodePudding user response:

I added but useless, I may not know where, shielding those? Can you help me change it, thank you

CodePudding user response:

 CFileDialog DLG (TRUE, ""," ", NULL, ""); 
If (DLG) DoModal ()==IDOK)
{
Cstrings STR=DLG. GetPathName ();

CComboBox * comb=(CComboBox *) GetDlgItem (IDC_COMBO1);
ASSERT (NULL!=comb - & gt; GetSafeHwnd ());
Combo - & gt; SetWindowText (STR);
}

CodePudding user response:

SetLBText

CodePudding user response:

Set after the UpdateData (FALSE); Have a try

CodePudding user response:

CFileDialog DLG (TRUE, ""," ", NULL, "");
If (DLG) DoModal ()==IDOK)
{
Cstrings STR=DLG. GetPathName ();

CComboBox * comb=(CComboBox *) GetDlgItem (IDC_COMBO1);
ASSERT (NULL!=comb - & gt; GetSafeHwnd ());
Comb - & gt; SetWindowText (STR);
}
I run for a moment, or not to display content in combobox edit box!
Set after the UpdateData (FALSE); It's nothing, and SetLBText is what?

CodePudding user response:

Void CxxxxDlg: : OnButton1 ()
{
//TODO: Add your the control notification handler code here
CFileDialog DLG (TRUE);//, ""," ", NULL, "");
If (DLG) DoModal ()==IDOK)
{
Cstrings STR=DLG. GetPathName ();

CComboBox * pComb=(CComboBox *) GetDlgItem (IDC_COMBO1);
ASSERT (NULL!=pComb - & gt; GetSafeHwnd ());
PComb - & gt; SetWindowText (STR);
}
}

No problem on vc6

CodePudding user response:

Ok, I'm vs2010, I in a moment, thank you!

CodePudding user response:

AddString must be added in the drop-down list,
To the ordinary reality, when it is edit box, SetWindowText enough,
  • Related