[C#] Tab Control แสดงข้อมูล

โค้ด

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

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (textBoxName.Text == "")
            {
                MessageBox.Show("You have to fill name.");
                return;
            }
            string strOut = "";
            strOut += "Name : " + textBoxName.Text + "\n";
            strOut += "Email : " + textBoxEmail.Text + "\n";
            strOut += "Tel : " + maskedTextBoxTel.Text + "\n";
            strOut += "Birth : " + dateTimePickerBirth.Value.ToLongDateString() + "\n";
            strOut += " - - - - - - - - - - - - - - - - \n";
            
            if (listBoxFootball.SelectedIndex == -1)
            {
                strOut += "You dont like any football team.\n";
            }
            else
            {
                strOut += "Football team : "+listBoxFootball.SelectedItem.ToString()+"\n";
            }
            
            if (listBoxProgramming.SelectedIndex == -1)
            {
                strOut += "You dont like any programming.\n";
            }
            else
            {
                strOut += "Program : " + listBoxProgramming.SelectedItem.ToString() + "\n";
            }
            strOut += " - - - - - - - - - - - - - - - - \n";

            strOut += "Opinion : " + textBoxOpinion.Text;
            MessageBox.Show(strOut);
        }
    }
}
Previous
Next Post »