找不到这个问题的答案,甚至没有任何问题。所以我要做的,是一个std::vector,也许只是一个普通的数组,复选框。
std::vector< System::Windows::Forms::CheckBox^ >m_items;
m_items.push_back( myCheckbox );
这是我目前拥有的,它显然不起作用。所以有没有人有任何想法,关于如何让它工作,因为我已经尝试了我能做的一切,但向量似乎不支持复选框。
如果您需要错误代码:
c:Program Files (x86)Microsoft Visual Studio 10.0VCincludexmemory(200): error C3699: '&&' : cannot use this indirection on type 'System::Windows::Forms::CheckBox ^'
1> c:Program Files (x86)Microsoft Visual Studio 10.0VCincludevector(421) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled
1> with
1> [
1> _Ty=System::Windows::Forms::CheckBox ^
1> ]
1> c:Program Files (x86)Microsoft Visual Studio 10.0VCincludevector(481) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled
1> with
1> [
1> _Ty=System::Windows::Forms::CheckBox ^,
1> _Alloc=std::allocator<System::Windows::Forms::CheckBox ^>
1> ]
1> d:programmingvc++ projectsmahi wcs race makermahi wcs race makerRestrictedItemsForm.h(69) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1> with
1> [
1> _Ty=System::Windows::Forms::CheckBox ^
1> ]
1>c:Program Files (x86)Microsoft Visual Studio 10.0VCincludevector(630): error C3699: '&&' : cannot use this indirection on type 'System::Windows::Forms::CheckBox ^'
1>c:Program Files (x86)Microsoft Visual Studio 10.0VCincludevector(655): error C3699: '&&' : cannot use this indirection on type 'System::Windows::Forms::CheckBox ^'
1>d:programmingvc++ projectsmahi wcs race makermahi wcs race makerRestrictedItemsForm.h(69): error C4368: cannot define 'm_items' as a member of managed 'MahiWCSRaceMaker::RestrictedItemsForm': mixed types are not supported
1>d:programmingvc++ projectsmahi wcs race makermahi wcs race makerRestrictedItemsForm.h(170): error C2663: 'std::vector<_Ty>::push_back' : 2 overloads have no legal conversion for 'this' pointer
常规std::vector
不支持CLR引用类型。相反,您必须使用cliext::vector
。包括以下内容:
#include <cliext/vector>
并与:
连用cliext::vector<System::Windows::Forms::CheckBox^> items;
items.push_back(myCheckBox);
当然,您也可以使用常规的。net集合,如List<T>
,其行为类似于vector
。