如何制作System :: Windows :: Forms :: Checkbox ^的向量/数组^ [英] How do I make a vector/array of System::Windows::Forms::Checkbox^
问题描述
找不到此问题的答案,甚至没有任何问题问到。
所以我想做的是一个std :: vector,也许只是一个普通的复选框。
Couldn't find any answer to this problem, or not even any questions asked. So what I'm trying to do, is a std::vector, maybe just a normal array, of Checkboxes.
std::vector< System::Windows::Forms::CheckBox^ >m_items;
m_items.push_back( myCheckbox );
这就是我目前所拥有的,显然没有用。
那么,有人对如何使其工作有任何想法,因为我已经尽力了,但是矢量似乎不支持Checkboxes。
That's what I currently have, and it clearly ain't working. So does anyone have any ideas, on how to get it working, cause I've tried everything I can, but vectors don't seem to support Checkboxes.
如果您需要错误代码:
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xmemory(200): error C3699: '&&' : cannot use this indirection on type 'System::Windows::Forms::CheckBox ^'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(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.0\VC\include\vector(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:\programming\vc++ projects\mahi wcs race maker\mahi wcs race maker\RestrictedItemsForm.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.0\VC\include\vector(630): error C3699: '&&' : cannot use this indirection on type 'System::Windows::Forms::CheckBox ^'
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(655): error C3699: '&&' : cannot use this indirection on type 'System::Windows::Forms::CheckBox ^'
1>d:\programming\vc++ projects\mahi wcs race maker\mahi wcs race maker\RestrictedItemsForm.h(69): error C4368: cannot define 'm_items' as a member of managed 'MahiWCSRaceMaker::RestrictedItemsForm': mixed types are not supported
1>d:\programming\vc++ projects\mahi wcs race maker\mahi wcs race maker\RestrictedItemsForm.h(170): error C2663: 'std::vector<_Ty>::push_back' : 2 overloads have no legal conversion for 'this' pointer
推荐答案
常规 std: :vector
不支持CLR引用类型。相反,您必须使用 cliext :: vector
一个>。包括以下内容:
The regular std::vector
does not support CLR reference types. Instead, you must use cliext::vector
. Include the following:
#include <cliext/vector>
并用于:
cliext::vector<System::Windows::Forms::CheckBox^> items;
items.push_back(myCheckBox);
当然,您也可以使用常规的.Net集合,例如 列表< T>
,其行为与<$ c $类似c> vector 。
Of course, you can also use the regular .Net collections, like List<T>
, which behaves similarly as a vector
.
这篇关于如何制作System :: Windows :: Forms :: Checkbox ^的向量/数组^的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!