C++ cli CPP Visual Studio 2017年版”;CLR表格“;。。。标签不会拿走我的绳子吗?

C++ cli CPP Visual Studio 2017年版”;CLR表格“;。。。标签不会拿走我的绳子吗?,c++-cli,clr,C++ Cli,Clr,我希望我的标签对象显示一个字符串或整数,但我似乎找不到问题 "System::Windows::Forms::Label::Text::set" cannot be called with the given argument list 参数类型为(std::string) 函数类型为System::Windows::Forms::Label^ 滚动到我的节目的最后,看看我在说什么 #pragma once #include <string> #include <sstre

我希望我的标签对象显示一个字符串或整数,但我似乎找不到问题

"System::Windows::Forms::Label::Text::set" cannot be called with the given argument list
参数类型为(
std::string

函数类型为
System::Windows::Forms::Label^

滚动到我的节目的最后,看看我在说什么

#pragma once
#include <string>
#include <sstream>
#include <stdio.h>
#include <iostream>


int result;



namespace PraythisWorksOMG {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;

    /// <summary>
    /// Summary for MyForm
    /// </summary>
    public ref class MyForm : public System::Windows::Forms::Form
    {
    public:
        MyForm(void)
        {
            InitializeComponent();
            //
            //TODO: Add the constructor code here
            //
        }

    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~MyForm()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::TextBox^  textBox3;
    private: System::Windows::Forms::Label^  label1;
    protected:

    private:
        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        void InitializeComponent(void)
        {
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->textBox3 = (gcnew System::Windows::Forms::TextBox());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->SuspendLayout();
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(74, 102);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(98, 34);
            this->button1->TabIndex = 0;
            this->button1->Text = L"button1";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
            // 
            // textBox1
            // 
            this->textBox1->Location = System::Drawing::Point(74, 169);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(100, 22);
            this->textBox1->TabIndex = 1;
            // 
            // textBox2
            // 
            this->textBox2->Location = System::Drawing::Point(74, 12);
            this->textBox2->Name = L"textBox2";
            this->textBox2->Size = System::Drawing::Size(100, 22);
            this->textBox2->TabIndex = 2;
            // 
            // textBox3
            // 
            this->textBox3->Location = System::Drawing::Point(74, 58);
            this->textBox3->Name = L"textBox3";
            this->textBox3->Size = System::Drawing::Size(100, 22);
            this->textBox3->TabIndex = 3;
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(88, 212);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(46, 17);
            this->label1->TabIndex = 4;
            this->label1->Text = L"label1";
            // 
            // MyForm
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(282, 253);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->textBox3);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->button1);
            this->Name = L"MyForm";
            this->Text = L"MyForm";
            this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
            this->ResumeLayout(false);
            this->PerformLayout();

        }
#pragma endregion
    private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
    }
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
    {


        int number;
        int radix;
        try
        {
            number = Convert::ToInt32(textBox1->Text);
            radix = Convert::ToInt32(textBox2->Text);
        }
        catch (...) // catch all Convert errors
        {

            MessageBox::Show("this isn't string");

        }
        if (radix < 2 || radix > 36)
        {
            MessageBox::Show("must be integers!");
        }
        else
        {
            do // conversion algorithm
            {
                char digit = number % radix;
                number /= radix;
                if (digit > 9) // for letters
                {
                    digit += 7; // add bias
                }
                digit += 0x30; // convert to ASCII
                result = digit + result;
            } while (number != 0);
        }






        std::string test = "test";
        label1->Text = "Test";
        label1->Text = test;




    }
    };
}
#pragma一次
#包括
#包括
#包括
#包括
int结果;
命名空间PraythisWorksOMG{
使用名称空间系统;
使用名称空间System::ComponentModel;
使用名称空间系统::集合;
使用命名空间System::Windows::Forms;
使用名称空间System::Data;
使用名称空间系统::绘图;
/// 
///我的表格摘要
/// 
公共引用类MyForm:public System::Windows::Forms::Form
{
公众:
我的表格(作废)
{
初始化组件();
//
//TODO:在此处添加构造函数代码
//
}
受保护的:
/// 
///清理所有正在使用的资源。
/// 
~MyForm()
{
if(组件)
{
删除组件;
}
}
私有:系统::Windows::窗体::按钮^button1;
private:System::Windows::Forms::TextBox^textBox1;
private:System::Windows::Forms::TextBox^textBox2;
private:System::Windows::Forms::TextBox^textBox3;
私有:系统::Windows::窗体::标签^label1;
受保护的:
私人:
/// 
///必需的设计器变量。
/// 
系统::组件模型::容器^组件;
#pragma区域Windows窗体设计器生成的代码
/// 
///设计器支持所需的方法-不修改
///此方法的内容与代码编辑器一起使用。
/// 
void初始化组件(void)
{
此->按钮1=(gcnew System::Windows::Forms::Button());
这->textBox1=(gcnewsystem::Windows::Forms::TextBox());
这->textBox2=(gcnewsystem::Windows::Forms::TextBox());
这->textBox3=(gcnewsystem::Windows::Forms::TextBox());
这->标签1=(gcnewsystem::Windows::Forms::Label());
此->SuspendLayout();
// 
//按钮1
// 
此->按钮1->位置=系统::图纸::点(74102);
此->按钮1->名称=L“按钮1”;
此->按钮1->尺寸=系统::图纸::尺寸(98,34);
此->按钮1->选项卡索引=0;
此->按钮1->文本=L“按钮1”;
此->按钮1->UseVisualStyleBackColor=true;
this->button1->Click+=gcnewsystem::EventHandler(this,&MyForm::button1\u Click);
// 
//文本框1
// 
此->文本框1->位置=系统::绘图::点(74169);
此->textBox1->Name=L“textBox1”;
此->文本框1->尺寸=系统::图纸::尺寸(100,22);
此->文本框1->选项卡索引=1;
// 
//文本框2
// 
此->文本框2->位置=系统::绘图::点(74,12);
此->textBox2->Name=L“textBox2”;
此->文本框2->尺寸=系统::图纸::尺寸(100,22);
此->文本框2->TabIndex=2;
// 
//文本框3
// 
此->文本框3->位置=系统::绘图::点(74,58);
此->textBox3->Name=L“textBox3”;
此->文本框3->尺寸=系统::图纸::尺寸(100,22);
此->文本框3->TabIndex=3;
// 
//标签1
// 
此->标签1->自动调整大小=真;
这个->标签1->位置=系统::图纸::点(88212);
此->标签1->名称=L“标签1”;
该->标签1->尺寸=系统::图纸::尺寸(46,17);
此->标签1->选项卡索引=4;
此->标签1->文本=L“标签1”;
// 
//MyForm
// 
这->自动缩放尺寸=系统::图纸::尺寸(8,16);
这->AutoScaleMode=System::Windows::Forms::AutoScaleMode::Font;
这->ClientSize=System::Drawing::Size(282253);
此->控制->添加(此->标签1);
此->控制->添加(此->文本框3);
此->控制->添加(此->文本框2);
此->控制->添加(此->文本框1);
此->控制->添加(此->按钮1);
此->名称=L“MyForm”;
此->文本=L“MyForm”;
this->Load+=gcnewsystem::EventHandler(this,&MyForm::MyForm\u Load);
此->恢复布局(错误);
此->执行布局();
}
#布拉格端区
private:System::Void MyForm_Load(System::Object^sender,System::EventArgs^e){
}
私有:系统::无效按钮1\u单击(系统::对象^sender,系统::事件参数^e)
{
整数;
整数基数;
尝试
{
数字=转换::到32(文本框1->文本);
基数=Convert::ToInt32(textBox2->Text);
}
catch(…)//捕获所有转换错误
{
MessageBox::Show(“这不是字符串”);
}
if(基数<2 | |基数>36)
{
MessageBox::Show(“必须是整数!”);
}
其他的
{
do//转换算法
{
字符位数=数字%基数;
数字/=基数;
如果(数字>9)//表示字母
{
数字+=7;//添加偏差
}
数字+=0x30;//转换为ASCII
结果=数字+结果;
}while(number!=0);
}
std::string test=“test”;
标签1->Text=“测试”;
标签1->文本=测试;
}
};
}

< /代码> .NET类不与 STD::String 交互,这是一种非托管C++标准库类型。

你通常不会想要的
label1->Text = gcnew System::String(test.c_str());