gpt4 book ai didi

c++ - 将项目添加到列表框的按钮出错

转载 作者:行者123 更新时间:2023-11-28 07:43:14 24 4
gpt4 key购买 nike

所以我用 C++ 在 mfc 对话框中做了一个简单的程序,它有一个添加按钮、一个删除按钮、一个列表框和一个编辑框。我希望能够在编辑框中输入一些内容,然后单击添加按钮,它将被添加到列表框中。但我收到此错误:

错误 1 ​​error C2679: binary '=': no operator found which takes a right-hand operand of type 'CEdit' (or there is no acceptable conversion)

这是添加按钮的代码:

void CtestDlg::OnBnClickedMybuttonadd()
{
CString str;
UpdateData();
str = m_myEditBox;
UpdateData(FALSE);
m_myListBox.AddString(str);
}

最佳答案

m_myEditBox 的类型是 CEdit。

您不能使用 = 运算符从 CEdit 对象分配字符串。

试试这个:

m_myEditBox.GetWindowText(str);

代替:

str = m_myEditBox;

关于c++ - 将项目添加到列表框的按钮出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15413374/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com