Visual studio 2010 将win32控制台应用程序转换为windows窗体应用程序

Visual studio 2010 将win32控制台应用程序转换为windows窗体应用程序,visual-studio-2010,class,c++-cli,windows-forms-designer,Visual Studio 2010,Class,C++ Cli,Windows Forms Designer,我正在尝试制作windows窗体这是Form1。h: #pragma once #include"student.h" namespace formApp { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace

我正在尝试制作windows窗体这是Form1。h:

#pragma once

#include"student.h"

namespace formApp {

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 Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
    Form1(void)
    {
        InitializeComponent();
        //
        //TODO: Add the constructor code here
        //
    }

protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~Form1()
    {
        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::TextBox^  textBox4;
private: System::Windows::Forms::TextBox^  textBox5;
private: System::Windows::Forms::Label^  label1;
private: System::Windows::Forms::Label^  label2;
private: System::Windows::Forms::Label^  label3;
private: System::Windows::Forms::Label^  label4;
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->textBox4 = (gcnew System::Windows::Forms::TextBox());
        this->textBox5 = (gcnew System::Windows::Forms::TextBox());
        this->label1 = (gcnew System::Windows::Forms::Label());
        this->label2 = (gcnew System::Windows::Forms::Label());
        this->label3 = (gcnew System::Windows::Forms::Label());
        this->label4 = (gcnew System::Windows::Forms::Label());
        this->SuspendLayout();
        // 
        // button1
        // 
        this->button1->Location = System::Drawing::Point(529, 209);
        this->button1->Name = L"button1";
        this->button1->Size = System::Drawing::Size(75, 23);
        this->button1->TabIndex = 0;
        this->button1->Text = L"max";
        this->button1->UseVisualStyleBackColor = true;
        this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
        // 
        // textBox1
        // 
        this->textBox1->Location = System::Drawing::Point(262, 76);
        this->textBox1->Name = L"textBox1";
        this->textBox1->Size = System::Drawing::Size(100, 20);
        this->textBox1->TabIndex = 1;
        // 
        // textBox2
        // 
        this->textBox2->Location = System::Drawing::Point(262, 132);
        this->textBox2->Name = L"textBox2";
        this->textBox2->Size = System::Drawing::Size(100, 20);
        this->textBox2->TabIndex = 2;
        // 
        // textBox3
        // 
        this->textBox3->Location = System::Drawing::Point(262, 181);
        this->textBox3->Name = L"textBox3";
        this->textBox3->Size = System::Drawing::Size(100, 20);
        this->textBox3->TabIndex = 3;
        // 
        // textBox4
        // 
        this->textBox4->Location = System::Drawing::Point(262, 37);
        this->textBox4->Name = L"textBox4";
        this->textBox4->Size = System::Drawing::Size(100, 20);
        this->textBox4->TabIndex = 4;
        // 
        // textBox5
        // 
        this->textBox5->Location = System::Drawing::Point(529, 256);
        this->textBox5->Name = L"textBox5";
        this->textBox5->Size = System::Drawing::Size(100, 20);
        this->textBox5->TabIndex = 5;
        // 
        // label1
        // 
        this->label1->AutoSize = true;
        this->label1->Location = System::Drawing::Point(206, 36);
        this->label1->Name = L"label1";
        this->label1->Size = System::Drawing::Size(15, 13);
        this->label1->TabIndex = 6;
        this->label1->Text = L"id";
        // 
        // label2
        // 
        this->label2->AutoSize = true;
        this->label2->Location = System::Drawing::Point(198, 80);
        this->label2->Name = L"label2";
        this->label2->Size = System::Drawing::Size(36, 13);
        this->label2->TabIndex = 7;
        this->label2->Text = L"mark1";
        // 
        // label3
        // 
        this->label3->AutoSize = true;
        this->label3->Location = System::Drawing::Point(209, 135);
        this->label3->Name = L"label3";
        this->label3->Size = System::Drawing::Size(36, 13);
        this->label3->TabIndex = 8;
        this->label3->Text = L"mark2";
        // 
        // label4
        // 
        this->label4->AutoSize = true;
        this->label4->Location = System::Drawing::Point(201, 181);
        this->label4->Name = L"label4";
        this->label4->Size = System::Drawing::Size(36, 13);
        this->label4->TabIndex = 9;
        this->label4->Text = L"mark3";
        // 
        // Form1
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = System::Drawing::Size(745, 290);
        this->Controls->Add(this->label4);
        this->Controls->Add(this->label3);
        this->Controls->Add(this->label2);
        this->Controls->Add(this->label1);
        this->Controls->Add(this->textBox5);
        this->Controls->Add(this->textBox4);
        this->Controls->Add(this->textBox3);
        this->Controls->Add(this->textBox2);
        this->Controls->Add(this->textBox1);
        this->Controls->Add(this->button1);
        this->Name = L"Form1";
        this->Text = L"Form1";
        this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
        this->ResumeLayout(false);
        this->PerformLayout();

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

             
             int id= System::Convert::ToInt32(textBox1->Text);
               int g1= System::Convert::ToInt32(textBox2->Text);
               int g2= System::Convert::ToInt32(textBox3->Text);
               int g3= System::Convert::ToInt32(textBox4->Text);
         s.setStudent(id,g1,g2,g3);

         textBox5->Text=  System::Convert::ToString(s.maxGrade());




         }
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
         }
};
}
#pragma一次
#包括“student.h”
名称空间格式{
使用名称空间系统;
使用名称空间System::ComponentModel;
使用名称空间系统::集合;
使用命名空间System::Windows::Forms;
使用名称空间System::Data;
使用名称空间系统::绘图;
/// 
///表格1摘要
/// 
public ref类Form1:public System::Windows::Forms::Form
{
公众:
表格1(无效)
{
初始化组件();
//
//TODO:在此处添加构造函数代码
//
}
受保护的:
/// 
///清理所有正在使用的资源。
/// 
~Form1()
{
if(组件)
{
删除组件;
}
}
私有:系统::Windows::窗体::按钮^button1;
private:System::Windows::Forms::TextBox^textBox1;
private:System::Windows::Forms::TextBox^textBox2;
private:System::Windows::Forms::TextBox^textBox3;
private:System::Windows::Forms::TextBox^textBox4;
private:System::Windows::Forms::TextBox^textBox5;
私有:系统::Windows::窗体::标签^label1;
私有:系统::Windows::窗体::标签^label2;
私有:系统::Windows::窗体::标签^label3;
私有:系统::Windows::窗体::标签^label4;
受保护的:
私人:
/// 
///必需的设计器变量。
/// 
系统::组件模型::容器^组件;
#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());
这->textBox4=(gcnewsystem::Windows::Forms::TextBox());
这->textBox5=(gcnewsystem::Windows::Forms::TextBox());
这->标签1=(gcnewsystem::Windows::Forms::Label());
这->label2=(gcnewsystem::Windows::Forms::Label());
这->label3=(gcnewsystem::Windows::Forms::Label());
这->label4=(gcnewsystem::Windows::Forms::Label());
此->SuspendLayout();
// 
//按钮1
// 
此->按钮1->位置=系统::图纸::点(529209);
此->按钮1->名称=L“按钮1”;
该->按钮1->尺寸=系统::图纸::尺寸(75,23);
此->按钮1->选项卡索引=0;
此->按钮1->文本=L“最大值”;
此->按钮1->UseVisualStyleBackColor=true;
此->按钮1->Click+=gcnewsystem::EventHandler(此,&Form1::按钮1\u Click);
// 
//文本框1
// 
此->文本框1->位置=系统::绘图::点(262,76);
此->textBox1->Name=L“textBox1”;
此->文本框1->尺寸=系统::图纸::尺寸(100,20);
此->文本框1->选项卡索引=1;
// 
//文本框2
// 
此->文本框2->位置=系统::绘图::点(262132);
此->textBox2->Name=L“textBox2”;
此->文本框2->尺寸=系统::图纸::尺寸(100,20);
此->文本框2->TabIndex=2;
// 
//文本框3
// 
此->文本框3->位置=系统::绘图::点(262181);
此->textBox3->Name=L“textBox3”;
此->文本框3->尺寸=系统::图纸::尺寸(100,20);
此->文本框3->TabIndex=3;
// 
//文本框4
// 
此->文本框4->位置=系统::绘图::点(262,37);
此->文本框4->Name=L“文本框4”;
此->文本框4->尺寸=系统::图纸::尺寸(100,20);
此->文本框4->选项卡索引=4;
// 
//文本框5
// 
此->文本框5->位置=系统::绘图::点(529256);
此->文本框5->Name=L“文本框5”;
此->文本框5->尺寸=系统::图纸::尺寸(100,20);
此->文本框5->TabIndex=5;
// 
//标签1
// 
此->标签1->自动调整大小=真;
该->标签1->位置=系统::图纸::点(206,36);
此->标签1->名称=L“标签1”;
该->标签1->尺寸=系统::图纸::尺寸(15,13);
此->标签1->选项卡索引=6;
此->标签1->文本=L“id”;
// 
//标签2
// 
此->标签2->自动调整大小=真;
该->标签2->位置=系统::图纸::点(198,80);
此->label2->名称=L“label2”;
该->标签2->尺寸=系统::图纸::尺寸(36,13);
该->标签2->选项卡索引=7;
此->标签2->文本=L“标记1”;
// 
//标签3
// 
此->标签3->自动调整大小=真;
这个->标签3->位置=系统::绘图::点(209135);
此->标签3->名称=L“标签3”;
该->标签3->尺寸=系统::图纸::尺寸(36,13);
该->标签3->选项卡索引=8;
此->标签3->文本=L“标记2”;
// 
//标签4
// 
此->标签4->自动调整大小=真;
这个->标签4->位置=系统::绘图::点(201181);
此->label4->名称=L“label4”;
这个->标签4->尺寸=系统::图纸::尺寸(36,13);
该->标签4->标签索引=9;
此->标签4->文本=L“标记3”;
// 
//表格1
// 
这->自动缩放尺寸=系统::图纸::尺寸(6,13);
这->AutoScaleMode=System::Windows::Forms::AutoScaleMode::Font;
这->ClientSize=System::Drawing::Size(745290);
此->控制->添加(此->标签4);
此->控制->添加(此->标签3);
此->控制->添加(此->标签2);
此->控制->添加(此->标签1);
此->控制->添加(此->文本框5);
此->控制->添加(此->文本框4);
此->控制->添加(此->文本框3);
此->控制->添加(此->文本框2);
此->控制->添加(此->文本框1);
#include<iostream>
#include<string>
using namespace std;

class student
{
int id;
int grade1,grade2,grade3;

public:

student()
{




}


void setStudent(int a,int b,int c,int d)
{
     id=a;
    grade1=b;
    grade2=c;
    grade3=d;


}


int maxGrade()
{
  int max=grade1;
  if(grade2>max)
    max=grade2;

  if(grade3>max)
  {
     max=grade3;
  
  }


  return max;




}



 };