| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 912 人关注过本帖
标题:CLR!?高手进,看一什么启用CLR
只看楼主 加入收藏
guer168
Rank: 2
等 级:论坛游民
帖 子:46
专家分:37
注 册:2010-3-19
结帖率:75%
收藏
 问题点数:0 回复次数:0 
CLR!?高手进,看一什么启用CLR
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Collections::Generic;
using namespace System::ComponentModel;
using namespace System::Drawing;
using namespace System::Text;
using namespace System::Windows::Forms;
using namespace std;

// This sample demonstrates the use of the
// DesignerSerializationVisibility attribute
// to serialize a collection of strings
// at design time.
namespace SerializationDemo
{

    public ref class SerializationDemoControl :
        public System::Windows::Forms::UserControl
    {
        // This is the TextBox contained by
        // the SerializationDemoControl.
    private:
        System::Windows::Forms::TextBox^ demoControlTextBox;

        // This field backs the Strings property.
    private:
        array<String^>^ stringsValue;



    public:
        SerializationDemoControl()
        {
            InitializeComponent();
            stringsValue = gcnew array<String^>(1);
        }

        // When the DesignerSerializationVisibility attribute has
        // a value of "Content" or "Visible" the designer will
        // serialize the property. This property can also be edited
        // at design time with a CollectionEditor.
    public:
        [DesignerSerializationVisibility(
            DesignerSerializationVisibility::Content)]
        property array<String^>^ Strings
        {
            array<String^>^ get()
            {
                return this->stringsValue;
            }
            void set(array<String^>^ value)
            {
                this->stringsValue = value;

                // Populate the contained TextBox with the values
                // in the stringsValue array.
                StringBuilder^ sb =
                    gcnew StringBuilder(this->stringsValue->Length);

                for (int i = 0; i < this->stringsValue->Length; i++)
                {
                    sb->Append(this->stringsValue[i]);
                    sb->Append(Environment::NewLine);
                }

                this->demoControlTextBox->Text = sb->ToString();
            }
        }

    private:
        void InitializeComponent()
        {
            this->demoControlTextBox =
                gcnew System::Windows::Forms::TextBox();
            this->SuspendLayout();

            // Settings for the contained TextBox control.
            this->demoControlTextBox->AutoSize = false;
            this->demoControlTextBox->Dock =
                System::Windows::Forms::DockStyle::Fill;
            this->demoControlTextBox->Location =
                System::Drawing::Point(5, 5);
            this->demoControlTextBox->Margin =
                System::Windows::Forms::Padding(0);
            this->demoControlTextBox->Multiline = true;
            this->demoControlTextBox->Name = "textBox1";
            this->demoControlTextBox->ReadOnly = true;
            this->demoControlTextBox->ScrollBars = ScrollBars::Vertical;
            this->demoControlTextBox->Size =
                System::Drawing::Size(140, 140);
            this->demoControlTextBox->TabIndex = 0;

            // Settings for SerializationDemoControl.
            this->Controls->Add(this->demoControlTextBox);
            this->Name = "SerializationDemoControl";
            this->Padding = System::Windows::Forms::Padding(5);
            this->ResumeLayout(false);
        }
    };

    public ref class SerializationDemoForm :
        public System::Windows::Forms::Form
    {

        SerializationDemoControl^ serializationDemoControl;


    public:
        SerializationDemoForm()
        {
            InitializeComponent();
            serializationDemoControl = nullptr;
        }

        // The Windows Forms Designer emits code to this method.
        // If an instance of SerializationDemoControl is added
        // to the form, the Strings will be serialized here.
    private:
        void InitializeComponent()
        {
            this->serializationDemoControl =
                gcnew SerializationDemo::SerializationDemoControl();
            this->SuspendLayout();
            //
            // serializationDemoControl
            //
            this->serializationDemoControl->Location =
                System::Drawing::Point(0, 0);
            this->serializationDemoControl->Name =
                "serializationDemoControl";
            this->serializationDemoControl->Padding =
                System::Windows::Forms::Padding(5);
            this->serializationDemoControl->TabIndex = 0;
            //
            // SerializationDemoForm
            //
            this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
            this->ClientSize = System::Drawing::Size(292, 273);
            this->Controls->Add(this->serializationDemoControl);
            this->Name = "SerializationDemoForm";
            this->Text = "Form1";
            this->ResumeLayout(false);

        }
    };
};

[STAThread]
int main()
{
    Application::EnableVisualStyles();
    Application::Run(gcnew SerializationDemo::SerializationDemoForm());
}

------ 已启动生成: 项目: 7, 配置: Debug Win32 ------
正在编译...
7.cpp
c:\documents and settings\administrator\桌面\c\7\7\7.cpp(1) : fatal error C1190: 托管目标代码需要“/clr”选项
生成日志保存在“file://c:\Documents and Settings\Administrator\桌面\C\7\7\Debug\BuildLog.htm”
7 - 1 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
搜索更多相关主题的帖子: CLR 
2010-04-04 13:38
快速回复:CLR!?高手进,看一什么启用CLR
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016197 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved