메뉴 건너뛰기

Programing

C# 게시판

전화번호부 구현

관리자 2018.12.30 17:35 조회 수 : 187

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

namespace _7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ControlCheck() == true)
            {
                var strArray = new string[] { this.txtName.Text, this.txtPhone.Text };
                var lvt = new ListViewItem(strArray);
                this.lvCall.Items.Add(lvt);
                this.txtName.Clear();
                this.txtPhone.Clear();
            }
            else
            {
                return;
            }
        }
        private Boolean ControlCheck()
        {
            if (this.txtName.Text == "")
            {
                this.txtName.Focus();
                return false;
            }
            else if (this.txtPhone.Text == "")
            {
                MessageBox.Show("전화번호를 입력하세요!!", "경고", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.txtPhone.Focus();
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}
이름과 전화번호를 입력후 입력버튼을 클릭하면 입력이 된다.

위로