Visual c++ 我需要让我的数组在文本框中显示它们的信息,但它';s不工作(更多细节如下) #pragma一次 命名空间StudentDataSearch{ 使用名称空间系统; 使用名称空间System::ComponentModel; 使用名称空间系统::集合;
我需要让我的数组在文本框中显示它们的信息,但它';s不工作(更多细节如下)Visual c++ 我需要让我的数组在文本框中显示它们的信息,但它';s不工作(更多细节如下) #pragma一次 命名空间StudentDataSearch{ 使用名称空间系统; 使用名称空间System::ComponentModel; 使用名称空间系统::集合;,visual-c++,c++-cli,Visual C++,C++ Cli,我需要让我的数组在文本框中显示它们的信息,但它';s不工作(更多细节如下) #pragma一次 命名空间StudentDataSearch{ 使用名称空间系统; 使用名称空间System::ComponentModel; 使用名称空间系统::集合; 使用命名空间System::Windows::Forms; 使用名称空间System::Data; 使用名称空间系统::绘图; /// ///表格1摘要 /// public ref类Form1:public System::Window
#pragma一次
命名空间StudentDataSearch{
使用名称空间系统;
使用名称空间System::ComponentModel;
使用名称空间系统::集合;
使用命名空间System::Windows::Forms;
使用名称空间System::Data;
使用名称空间系统::绘图;
///
///表格1摘要
///
public ref类Form1:public System::Windows::Forms::Form
{
公众:
表格1(无效)
{
初始化组件();
//
//TODO:在此处添加构造函数代码
//
}
受保护的:
///
///清理所有正在使用的资源。
///
~Form1()
{
if(组件)
{
删除组件;
}
}
私有:系统::Windows::窗体::按钮^BTN搜索;
私有:系统::Windows::窗体::标签^Course\u ID1;
受保护的:
私有:系统::Windows::窗体::文本框^TXTARGETID;
private:System::Windows::Forms::GroupBox^groupBox1;
私有:系统::Windows::窗体::文本框^TXT座位;
私有:系统::Windows::窗体::标签^Seats;
私有:系统::Windows::窗体::文本框^txtID;
私有:系统::Windows::窗体::标签^Course\u ID;
private:System::Windows::Forms::TextBox^txtName;
私有:系统::Windows::窗体::标签^Course\u名称2;
私有:系统::Windows::窗体::按钮^button1;
私人:
///
///必需的设计器变量。
///
系统::组件模型::容器^组件;
#pragma区域Windows窗体设计器生成的代码
///
///设计器支持所需的方法-不修改
///此方法的内容与代码编辑器一起使用。
///
void初始化组件(void)
{
这->btnSearch=(gcnew System::Windows::Forms::Button());
此->课程(gcnew System::Windows::Forms::Label());
这->txtTargetID=(gcnew System::Windows::Forms::TextBox());
this->groupBox1=(gcnewsystem::Windows::Forms::GroupBox());
这->txtSeats=(gcnewsystem::Windows::Forms::TextBox());
这->座位=(gcnew System::Windows::Forms::Label());
这->txtID=(gcnewsystem::Windows::Forms::TextBox());
这->课程ID=(gcnew System::Windows::Forms::Label());
这->txtName=(gcnewsystem::Windows::Forms::TextBox());
这->课程名称2=(gcnew System::Windows::Forms::Label());
此->按钮1=(gcnew System::Windows::Forms::Button());
此->groupBox1->SuspendLayout();
此->SuspendLayout();
//
//btnSearch
//
此->BTN搜索->位置=系统::图纸::点(12,12);
此->BTN搜索->名称=L“BTN搜索”;
这->BTN搜索->尺寸=系统::图纸::尺寸(144,39);
此->BTN搜索->选项卡索引=0;
此->BTN搜索->文本=L“按课程ID搜索”;
此->BTN搜索->UseVisualStyleBackColor=true;
this->btnSearch->Click+=gcnewsystem::EventHandler(this,&Form1::btnSearch\u Click);
//
//课程编号1
//
此->课程号->自动调整大小=真;
这个->课程号1->位置=系统::绘图::点(317,28);
此->课程编号1->名称=L“课程编号1”;
这->课程号1->尺寸=系统::图纸::尺寸(54,13);
本->课程号1->TabIndex=1;
此->课程ID 1->文本=L“课程ID”;
//
//txtTargetID
//
此->TXTARGETID->位置=系统::绘图::点(377,25);
此->txtTargetID->Name=L“txtTargetID”;
此->TXTARGETID->大小=系统::绘图::大小(100,20);
此->txtTargetID->TabIndex=2;
//
//groupBox1
//
此->groupBox1->控件->添加(此->txtSeats);
此->groupBox1->控件->添加(此->座位);
此->groupBox1->控件->添加(此->txtID);
此->groupBox1->控件->添加(此->课程ID);
此->groupBox1->控件->添加(此->txtName);
此->groupBox1->控件->添加(此->课程名称2);
此->groupBox1->位置=系统::绘图::点(12145);
此->groupBox1->名称=L“groupBox1”;
此->groupBox1->尺寸=系统::图纸::尺寸(465140);
此->groupBox1->选项卡索引=3;
此->groupBox1->TabStop=false;
此->groupBox1->Text=L“搜索结果”;
//
//TXT座椅
//
这->txtSeats->位置=系统::绘图::点(301,81);
这->txtSeats->Name=L“txtSeats”;
这->txtSeats->尺寸=系统::图纸::尺寸(100,20);
这->txtSeats->TabIndex=5;
//
//座位
//
此->座椅->自动调整大小=真;
这个->座位->位置=系统::图纸::点(298,65);
此->座位->名称=L“座位”;
这个->座位->尺寸=系统::图纸::尺寸(34,13);
该->座位->选项卡索引=4;
此->座位->文本=L“座位”;
//
//txtID
//
这个->txtID->位置=系统::绘图::点(204,81);
此->txtID->Name=L“txtID”;
这个->txtID->尺寸=系统::图纸::尺寸(91,20);
此->txtID->TabIndex=3;
//
//课程号
//
此->课程ID->自动调整大小=真;
该->课程ID->位置=系统::绘图::点(206,65);
此->课程ID->名称=L“课程ID”;
该->课程ID->尺寸=系统::图纸::尺寸(54,13);
此->课程ID->选项卡索引=2;
这个->库尔
#pragma once
namespace StudentDataSearch {
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^ btnSearch;
private: System::Windows::Forms::Label^ Course_ID1;
protected:
private: System::Windows::Forms::TextBox^ txtTargetID;
private: System::Windows::Forms::GroupBox^ groupBox1;
private: System::Windows::Forms::TextBox^ txtSeats;
private: System::Windows::Forms::Label^ Seats;
private: System::Windows::Forms::TextBox^ txtID;
private: System::Windows::Forms::Label^ Course_ID;
private: System::Windows::Forms::TextBox^ txtName;
private: System::Windows::Forms::Label^ Course_Names2;
private: System::Windows::Forms::Button^ button1;
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->btnSearch = (gcnew System::Windows::Forms::Button());
this->Course_ID1 = (gcnew System::Windows::Forms::Label());
this->txtTargetID = (gcnew System::Windows::Forms::TextBox());
this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
this->txtSeats = (gcnew System::Windows::Forms::TextBox());
this->Seats = (gcnew System::Windows::Forms::Label());
this->txtID = (gcnew System::Windows::Forms::TextBox());
this->Course_ID = (gcnew System::Windows::Forms::Label());
this->txtName = (gcnew System::Windows::Forms::TextBox());
this->Course_Names2 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->groupBox1->SuspendLayout();
this->SuspendLayout();
//
// btnSearch
//
this->btnSearch->Location = System::Drawing::Point(12, 12);
this->btnSearch->Name = L"btnSearch";
this->btnSearch->Size = System::Drawing::Size(144, 39);
this->btnSearch->TabIndex = 0;
this->btnSearch->Text = L"Search by Course ID";
this->btnSearch->UseVisualStyleBackColor = true;
this->btnSearch->Click += gcnew System::EventHandler(this, &Form1::btnSearch_Click);
//
// Course_ID1
//
this->Course_ID1->AutoSize = true;
this->Course_ID1->Location = System::Drawing::Point(317, 28);
this->Course_ID1->Name = L"Course_ID1";
this->Course_ID1->Size = System::Drawing::Size(54, 13);
this->Course_ID1->TabIndex = 1;
this->Course_ID1->Text = L"Course ID";
//
// txtTargetID
//
this->txtTargetID->Location = System::Drawing::Point(377, 25);
this->txtTargetID->Name = L"txtTargetID";
this->txtTargetID->Size = System::Drawing::Size(100, 20);
this->txtTargetID->TabIndex = 2;
//
// groupBox1
//
this->groupBox1->Controls->Add(this->txtSeats);
this->groupBox1->Controls->Add(this->Seats);
this->groupBox1->Controls->Add(this->txtID);
this->groupBox1->Controls->Add(this->Course_ID);
this->groupBox1->Controls->Add(this->txtName);
this->groupBox1->Controls->Add(this->Course_Names2);
this->groupBox1->Location = System::Drawing::Point(12, 145);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->Size = System::Drawing::Size(465, 140);
this->groupBox1->TabIndex = 3;
this->groupBox1->TabStop = false;
this->groupBox1->Text = L"Search Results";
//
// txtSeats
//
this->txtSeats->Location = System::Drawing::Point(301, 81);
this->txtSeats->Name = L"txtSeats";
this->txtSeats->Size = System::Drawing::Size(100, 20);
this->txtSeats->TabIndex = 5;
//
// Seats
//
this->Seats->AutoSize = true;
this->Seats->Location = System::Drawing::Point(298, 65);
this->Seats->Name = L"Seats";
this->Seats->Size = System::Drawing::Size(34, 13);
this->Seats->TabIndex = 4;
this->Seats->Text = L"Seats";
//
// txtID
//
this->txtID->Location = System::Drawing::Point(204, 81);
this->txtID->Name = L"txtID";
this->txtID->Size = System::Drawing::Size(91, 20);
this->txtID->TabIndex = 3;
//
// Course_ID
//
this->Course_ID->AutoSize = true;
this->Course_ID->Location = System::Drawing::Point(206, 65);
this->Course_ID->Name = L"Course_ID";
this->Course_ID->Size = System::Drawing::Size(54, 13);
this->Course_ID->TabIndex = 2;
this->Course_ID->Text = L"Course ID";
//
// txtName
//
this->txtName->Location = System::Drawing::Point(25, 81);
this->txtName->Name = L"txtName";
this->txtName->Size = System::Drawing::Size(173, 20);
this->txtName->TabIndex = 1;
//
// Course_Names2
//
this->Course_Names2->AutoSize = true;
this->Course_Names2->Location = System::Drawing::Point(22, 65);
this->Course_Names2->Name = L"Course_Names2";
this->Course_Names2->Size = System::Drawing::Size(71, 13);
this->Course_Names2->TabIndex = 0;
this->Course_Names2->Text = L"Course Name";
//
// button1
//
this->button1->Location = System::Drawing::Point(12, 57);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(144, 39);
this->button1->TabIndex = 4;
this->button1->Text = L"Search by Course Name";
this->button1->UseVisualStyleBackColor = true;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(519, 297);
this->Controls->Add(this->button1);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->txtTargetID);
this->Controls->Add(this->Course_ID1);
this->Controls->Add(this->btnSearch);
this->Name = L"Form1";
this->Text = L"Student Data Search";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->groupBox1->ResumeLayout(false);
this->groupBox1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: array<String^>^ CourseArr;
private: array<String^>^ CourseID;
private: array<Int32^>^ SeatsArr;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
// Course Names
CourseArr = gcnew array<String^>(9);
CourseArr->SetValue("Computer Sci 1511", 0);
CourseArr->SetValue("Computer Sci 1521", 1);
CourseArr->SetValue("Composition 1120", 2);
CourseArr->SetValue("Math 1296", 3);
CourseArr->SetValue("Physics 1120", 4);
CourseArr->SetValue("Biology 1100", 5);
CourseArr->SetValue("Chemistry 1100", 6);
CourseArr->SetValue("Anthropology 1210", 7);
CourseArr->SetValue("Economics 1000", 8);
// Course ID
CourseID = gcnew array<String^>(9);
CourseID->SetValue("123", 0);
CourseID->SetValue("124", 1);
CourseID->SetValue("135", 2);
CourseID->SetValue("145", 3);
CourseID->SetValue("146", 4);
CourseID->SetValue("149", 5);
CourseID->SetValue("155", 6);
CourseID->SetValue("162", 7);
CourseID->SetValue("175", 8);
//Seats Avaliable
SeatsArr->SetValue("0", 0);
SeatsArr->SetValue("25", 1);
SeatsArr->SetValue("14", 2);
SeatsArr->SetValue("5", 3);
SeatsArr->SetValue("0", 4);
SeatsArr->SetValue("20", 5);
SeatsArr->SetValue("17", 6);
SeatsArr->SetValue("0", 7);
SeatsArr->SetValue("12", 8);
}
private: System::Void btnSearch_Click(System::Object^ sender, System::EventArgs^ e) {
int course;
int id;
int seats;
for (int i = 0; i < course; i++)
{
txtName->Text = CourseArr[i]->ToString();
txtID->Text =CourseID[i]->ToString();
txtSeats->Text = SeatsArr[i]->ToString();
course = CourseArr[i]->ToString();
id = CourseID[i]->ToString();
seats = SeatsArr[i]->ToString();
}
}
};
}