2021년 목표설정

이미지
기본적으로 작년에 달성하지 못한 것들을 하려고 생각중인데..코로나가 언제까지 이어질지, 한국이나 북해도는 갈 수 있을지..자격증은 응시 가능할지..여러가지가 불확실하다. 2021년은 무엇보다 정신적인 부분과 경제적인 부분에 중점을 두고 조금 더 치열하게 지내보고 싶다. 일본나이로도 30대 마지막 해, 이제 불혹에 접어드는 나이..복잡하지만 심플하게. 육체적목표 : 트라이에슬론 스탠다드 도전하기 정신적 : 자격증2개 도전 + 자체개발 서비스 론칭 가족적 : 가정의 평화를 유지하기 경제적 : 외식과 유흥비를 줄이고 부수입을 늘려서 결과적으로 저축하기 사회적 : 목표세미나를 포함해서 민단과 개인인맥의 활성화와 교류를 촉진하기

C# 프로그래밍 예제 - 다섯 번째

[개체 배열]

[개요] 알파벳 버튼을 누르면 새 창이 뜨고 그 창에 무슨 버튼을 눌렀는지 나오게 만들어라.
          버튼은 배열을 사용하여 만들 것.

[ Source ]
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace array2
{
 /// <summary>
 /// Summary description for Form1.
 /// </summary>
 ///
 public class Form1 : System.Windows.Forms.Form
 {
  /// <summary>
  /// Required designer variable.
  /// </summary>
  ///
  Button[] objButton; // 버튼 배열 선언
  private System.ComponentModel.Container components = null;
  public Form1()
  {
   //
   // Required for Windows Form Designer support
   //
   InitializeComponent();
   //
   // TODO: Add any constructor code after InitializeComponent call
   //
  }
  /// <summary>
  /// Clean up any resources being used.
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }
  #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>
  private void InitializeComponent()
  {
   //
   // Form1
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(416, 309);
   this.Name = "Form1";
   this.Text = "알파벳 출력기";
   this.Load += new System.EventHandler(this.Form1_Load);
  }
  #endregion
  /// <summary>
  /// The main entry point for the application.
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }
 private void Form1_Load(object sender, System.EventArgs e)
  {
   // 버튼에 들어갈 알파벳
   char[] arrButton = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X'};
    // 버튼을 24개 만듦
 objButton=new Button[arrButton.Length];
 
    int x = 0, y = 0;
   for ( int j = 0 ; j < 3; j++ )
   {
    x = 0;
    for ( int i = 0 ; i < 8; i++ )
    {
     x = 20 + ( i * 42 ); // 버튼이 만들어질 x,y 좌표
     y = 30 + ( j * 52 ); // 규칙성 있게 x,y를 변화시킴
     objButton[i + (8 * j)] = new Button();
     objButton[i + (8 * j)].FlatStyle = FlatStyle.Standard;
     objButton[i + (8 * j)].Size = new System.Drawing.Size(40,40);
     objButton[i + (8 * j)].Location = new System.Drawing.Point(x,y);
     objButton[i + (8 * j)].Name = Convert.ToString(arrButton[i + (8*j)]);
     objButton[i + (8 * j)].Text = Convert.ToString(arrButton[i + (8*j)]);
     objButton[i + (8 * j)].Click += new System.EventHandler(this.Button_Click);
     // 위의 속성대로 버튼이 추가된다.
     this.Controls.Add(objButton[i + (8 * j)]);
    }
   }
  }

  // 버튼 클릭 이벤트
  private void Button_Click(object sender, System.EventArgs e)
  {
   MessageBox.Show("클릭하신 버튼은 " + ((Button)sender).Text + " 입니다.","이런 ㅂㅂㅂ");
  }
 }
}

댓글

이 블로그의 인기 게시물

성공적인 소셜커머스를 위한 10단계 전략

[C# & LINQ] 랜덤으로 데이터를 한 개 추출하는 방법

[메모] PostgreSQL에서 Insert 하는 경우 자동채번 PK가 중복에러 나는 경우