C++ > CLI:アップダウンコントロール

基本プロジェクトにアップダウンコントロールを配置します。
NumericUpDown という名前です。


フォントのサイズを16にして Bold を True にします。


ビルドして実行してみましょう。

MyForm.cpp

#pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
#include "MyForm.h"

using namespace Project1;

[STAThreadAttribute]
int main(){
 MyForm ^form1 = gcnew MyForm;
 form1->ShowDialog();
 return 0;
}

MyForm.h

#pragma once

namespace Project1 {

 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>
 /// MyForm の概要
 /// </summary>
 public ref class MyForm : public System::Windows::Forms::Form
 {
 public:
  MyForm(void)
  {
   InitializeComponent();
   //
   //TODO: ここにコンストラクター コードを追加します
   //
  }

 protected:
  /// <summary>
  /// 使用中のリソースをすべてクリーンアップします。
  /// </summary>
  ~MyForm()
  {
   if (components)
   {
    delete components;
   }
  }
 private: System::Windows::Forms::NumericUpDown^  numericUpDown1;
 protected:

 protected:


 protected:

 private:
  /// <summary>
  /// 必要なデザイナー変数です。
  /// </summary>
  System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
  /// <summary>
  /// デザイナー サポートに必要なメソッドです。このメソッドの内容を
  /// コード エディターで変更しないでください。
  /// </summary>
  void InitializeComponent(void)
  {
   this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
   (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->BeginInit();
   this->SuspendLayout();
   //
   // numericUpDown1
   //
   this->numericUpDown1->Font = (gcnew System::Drawing::Font(L"MS UI Gothic", 16, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
    static_cast<System::Byte>(128)));
   this->numericUpDown1->Location = System::Drawing::Point(88, 96);
   this->numericUpDown1->Name = L"numericUpDown1";
   this->numericUpDown1->Size = System::Drawing::Size(120, 29);
   this->numericUpDown1->TabIndex = 0;
   //
   // MyForm
   //
   this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
   this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
   this->ClientSize = System::Drawing::Size(284, 261);
   this->Controls->Add(this->numericUpDown1);
   this->Name = L"MyForm";
   this->Text = L"Hello C++/CLI World !!";
   (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->EndInit();
   this->ResumeLayout(false);

  }
#pragma endregion

 };
}

 

 

 

 

 

 

最終更新:2013年09月20日 17:40
添付ファイル