==> Program.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace 체중관리프로그램
{
    static class Program
    {
        /// <summary>
        /// 해당 응용 프로그램의 주 진입점입니다.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Frm입력());
        }
    }
}



==============================================================================================



==> Weight.cs


using System;

public class Weight
{
    public int 반 { get; set; }
    public int 번호 { get; set; }
    public int 몸무게 { get; set; }
    public Weight(int 반, int 번호, int 몸무게)
    {
        this.반 = 반; this.번호 = 번호; this.몸무게 = 몸무게;
    }
}



==============================================================================================



==> Frm입력.cs



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 체중관리프로그램
{
   
    public partial class Frm입력 : Form
    {
        public Frm입력()
        {
            InitializeComponent();
            lst = new List<Weight>();
        }

        private List<Weight> lst;
        private void btn입력_Click(object sender, EventArgs e)
        {
            lst.Add(new Weight(Convert.ToInt32(txt반.Text)
                , Convert.ToInt32(txt번호.Text)
                , Convert.ToInt32(txt몸무게.Text)));
            // 텍스트박스 클리어
            txt반.Text = "";
            txt번호.Text = String.Empty;
            txt몸무게.Clear();
        }

        private void btn출력_Click(object sender, EventArgs e)
        {
            Frm출력 f = new Frm출력(lst);
            f.Show();       // 출력 창 띄우고,
            this.Hide();    // 현재 폼 숨기고
        }
    }
}



==============================================================================================



==> Frm출력.cs



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 체중관리프로그램
{
    public partial class Frm출력 : Form
    {
        public Frm출력()
        {
            InitializeComponent();
        }

        private List<Weight> lst;
        public Frm출력(List<Weight> lst)
        {
            InitializeComponent(); // 폼 초기화
            this.lst = lst;
        }

        private void Frm출력_Load(object sender, EventArgs e)
        {
            this.ctlPrint.DataSource = lst; // 출력(알아서)
        }
    }
}



< 실행결과 >


==> 입력 폼






==> 출력 폼



Posted by holland14
: