none
ㅁㅁ RRS feed

  • 질문

  • ======================================탭컨트롤실습=========================================

     

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

            private void radioButton1_CheckedChanged(object sender, EventArgs e)
            {
                tabControl1.Alignment = TabAlignment.Top;
                label1.Text = radioButton1.Text;
            }

            private void radioButton2_CheckedChanged(object sender, EventArgs e)
            {
                tabControl1.Alignment = TabAlignment.Bottom;
                label1.Text = radioButton2.Text;
            }

            private void radioButton3_CheckedChanged(object sender, EventArgs e)
            {
                tabControl1.Alignment = TabAlignment.Left;
                label1.Text = radioButton3.Text;
            }

            private void radioButton4_CheckedChanged(object sender, EventArgs e)
            {
                tabControl1.Alignment = TabAlignment.Right;
                label1.Text = radioButton4.Text;
            }

            private void radioButton5_CheckedChanged(object sender, EventArgs e)
            {
                tabControl1.Appearance = TabAppearance.Normal;
                label1.Text = radioButton5.Text;
            }

            private void radioButton6_CheckedChanged(object sender, EventArgs e)
            {
                tabControl1.Appearance = TabAppearance.Buttons;
                label1.Text = radioButton6.Text;
            }

            private void radioButton7_CheckedChanged(object sender, EventArgs e)
            {
                tabControl1.Appearance = TabAppearance.FlatButtons;
                label1.Text = radioButton7.Text;
            }

            private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
            {
                label1.Text = dateTimePicker1.Value.ToString();
            }

            private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
            {
                label1.Text = monthCalendar1.SelectionRange.Start.ToString();
            }

          
           
        }
    }

    =============================================계산기 실습=====================================

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

            private void button_click1(object sender, EventArgs e)
            {
                textBox1.Text = string.Empty;
                textBox2.Text = string.Empty;
                textBox3.Text = string.Empty;
            }

            private void button_click2(object sender, EventArgs e)
            {
                double result, a, b;
                a = double.Parse(textBox1.Text);
                b = double.Parse(textBox2.Text);
                result = a + b;
                textBox3.Text = result.ToString("0.00");

            }

            private void button_click3(object sender, EventArgs e)
            {
                double result, a, b;
                a = double.Parse(textBox1.Text);
                b = double.Parse(textBox2.Text);
                result = a - b;
                textBox3.Text = result.ToString("0.00");
            }

            private void button_click4(object sender, EventArgs e)
            {
                double result, a, b;
                a = double.Parse(textBox1.Text);
                b = double.Parse(textBox2.Text);
                result = a * b;
                textBox3.Text = result.ToString("0.00");
            }

            private void button_click5(object sender, EventArgs e)
            {
                double result, a, b;
                a = double.Parse(textBox1.Text);
                b = double.Parse(textBox2.Text);
                result = a / b;
                textBox3.Text = result.ToString("0.00");
            }
          


        }
    }

    ============================리스트뷰 실습==========================

     

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

            private void radioButton1_CheckedChanged(object sender, EventArgs e)
            {
                listView1.View = View.LargeIcon;
            }

            private void radioButton2_CheckedChanged(object sender, EventArgs e)
            {
                listView1.View = View.SmallIcon;
            }

            private void radioButton3_CheckedChanged(object sender, EventArgs e)
            {
                listView1.View = View.List;
            }

            private void radioButton4_CheckedChanged(object sender, EventArgs e)
            {
                listView1.View = View.Details;
            }

            private void button1_Click(object sender, EventArgs e)
            {
                ListViewItem item = new ListViewItem(textBox1.Text, Int32.Parse(textBox5.Text));
                 
                item.SubItems.Add(textBox2.Text);
                item.SubItems.Add(textBox3.Text);
                item.SubItems.Add(textBox4.Text);
                item.SubItems.Add(textBox5.Text);
              
                listView1.Items.Add(item);
            }

           
        }
    }

    ===========toolstrip 실습======================================
    <<<<form1>>>>>>>


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

            private void 큰아이콘ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                listView1.View = View.LargeIcon;
            }

            private void 작은아이콘ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                listView1.View = View.SmallIcon;
            }

            private void 간단히ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                listView1.View = View.List;
            }

            private void 자세히ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                listView1.View = View.Details;
            }

            private void 입력대화상자ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Form2 dlg = new Form2(this);
                dlg.Show();
            }
        }
    }


    <<<<<<<<<<<<<<<<form2>>>>>>>>>>>>>

     

    namespace PJW_190
    {
        public partial class Form2 : Form
        {
            private Form1 dlg;

            public Form2(Form1 a)
            {
                InitializeComponent();
                dlg = a;
            }

            private void button1_Click_1(object sender, EventArgs e)
            {
                ListViewItem item = new ListViewItem(textBox1.Text, int.Parse(textBox4.Text));
                item.SubItems.Add(textBox2.Text);
                item.SubItems.Add(textBox3.Text);
                dlg.listView1.Items.Add(item);
                textBox1.Text = string.Empty;
                textBox2.Text = string.Empty;
                textBox3.Text = string.Empty;
                textBox4.Text = string.Empty;
            }

            private void button2_Click(object sender, EventArgs e)
            {
                Close();
            }
        }


    }


    =================웹브라우져 미디어추가===========================
    <<<<<<<<<<form1>>>>>>>>>>>>>


    namespace PJW_321
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                webBrowser1.Navigate("www.naver.com");
            }

            private void toolStripButton1_Click(object sender, EventArgs e)
            {
                webBrowser1.GoBack();
            }

            private void toolStripButton2_Click(object sender, EventArgs e)
            {
                webBrowser1.GoForward();
            }

            private void toolStripButton3_Click(object sender, EventArgs e)
            {
                webBrowser1.GoHome();
            }

            private void toolStripButton4_Click(object sender, EventArgs e)
            {
                webBrowser1.GoSearch();
            }

            private void comboBox1_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    webBrowser1.Navigate(comboBox1.Text);
                    comboBox1.Items.Insert(0, comboBox1.Text);
                }
            }

            private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                webBrowser1.Navigate(comboBox1.Text.ToString());
            }

            private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
            {
                comboBox1.Text = webBrowser1.Url.ToString();
                toolStripStatusLabel1.Text = webBrowser1.Url.ToString();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                webBrowser1.Navigate(comboBox1.Text.ToString());
                comboBox1.Items.Insert(0, comboBox1.Text);
            }

            private void toolStripButton5_Click(object sender, EventArgs e)
            {
                Form2 dlg = new Form2();
                dlg.Show();


            }

            private void Form1_Load(object sender, EventArgs e)
            {

            }
        }
    }

     

    <<<<<<<<<<form2>>>>>>>>>>>>>>>>

     

    namespace PJW_321
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }

            private void 종료ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Close();
            }

            private void 열기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                openFileDialog1.Filter = "동영상파일(*.mpg;*.mpeg;*.avi;*.divx;)|*.mpg;*.mpeg;*.avi;*.divx";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    axWindowsMediaPlayer1.URL = openFileDialog1.FileName;
                                       
            }
        }
    }


    ==========================즐겨찾기 숙제=============================================

    <<<<<<<<<<<<<<form1>>>>>>>>>>>>>>

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


            }

            private void Form1_Load(object sender, EventArgs e)
            {
                webBrowser1.Navigate("www.suwon.ac.kr");
                comboBox1.Text = "www.suwon.ac.kr";
            }

            private void toolStripMenuItem2_Click(object sender, EventArgs e)
            {
                Form2 dlg = new Form2(this);
                dlg.Show();
            }

            private void toolStripButton1_Click(object sender, EventArgs e)
            {
                webBrowser1.GoBack();
            }

            private void toolStripButton2_Click(object sender, EventArgs e)
            {
                webBrowser1.GoForward();
            }

            private void toolStripButton3_Click(object sender, EventArgs e)
            {
                webBrowser1.Stop();
            }

            private void toolStripButton4_Click(object sender, EventArgs e)
            {
                webBrowser1.Refresh();
            }

            private void toolStripButton5_Click(object sender, EventArgs e)
            {
                webBrowser1.GoHome();
            }

            private void toolStripButton6_Click(object sender, EventArgs e)
            {
                webBrowser1.GoSearch();
            }

          
            private void menu_Click(object sender, EventArgs e)
            {
                comboBox1.Text = ((ToolStripMenuItem)sender).Text;
                webBrowser1.Navigate(((ToolStripMenuItem)sender).Text);

            }

            private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
            {
                toolStripStatusLabel1.Text = Convert.ToString(e.Url);
                comboBox1.Text = Convert.ToString(e.Url);
            }

            private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                webBrowser1.Navigate(comboBox1.Text);
            }

            private void button1_Click(object sender, EventArgs e)
            {
                webBrowser1.Navigate(comboBox1.Text);
                comboBox1.Items.Add(comboBox1.Text); 
            }

            private void comboBox1_KeyDown(object sender, KeyEventArgs e)
            {

                if (e.KeyCode == Keys.Enter)
                {
                    webBrowser1.Navigate(comboBox1.Text);
                    comboBox1.Items.Add(comboBox1.Text);

                }
            }

           


        }
    }


    <<<<<<<<<<<<<<<<<form2>>>>>>>>>>>>>>>>>>


    namespace R_LSC06
    {
        public partial class Form2 : Form
        {

            private Form1 dlg;

            public Form2(Form1 a)
            {
                InitializeComponent();
                dlg = a;
            }

          

            private void menu_Click(object sender, EventArgs e)
            {
                dlg.comboBox1.Text = ((ToolStripMenuItem)sender).Text;
                dlg.webBrowser1.Navigate(((ToolStripMenuItem)sender).Text);

            }

            private void button1_Click_1(object sender, EventArgs e)
            {
                ToolStripMenuItem menu = new ToolStripMenuItem(textBox1.Text);
                menu.Click += new EventHandler(menu_Click);
                dlg.toolStripMenuItem1.DropDownItems.Add(menu);

                Close();
            }

     

     

        }
    }

    =======================리스트뷰 ADDR_CARD 추가, 제거, 삭제, 정렬==숙제================

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

    namespace R_PJW05
    {
        public partial class Form1 : Form
        {
            ADDR_CARD card;
            ArrayList List = new ArrayList();
            public Form1()
            {
                InitializeComponent();
                radioButton4.Checked = true;
                comboBox1.SelectedIndex = 0;
            }

            private void radioButton1_CheckedChanged(object sender, EventArgs e)
            {
                listView1.View = View.LargeIcon;
            }

            private void radioButton2_CheckedChanged(object sender, EventArgs e)
            {
                listView1.View = View.SmallIcon;
            }

            private void radioButton3_CheckedChanged(object sender, EventArgs e)
            {
                listView1.View = View.List;
            }

            private void radioButton4_CheckedChanged(object sender, EventArgs e)
            {
                listView1.View = View.Details;
            }

            private void button1_Click(object sender, EventArgs e)
            {
                card = new ADDR_CARD();
                card.name = textBox1.Text;
                card.addrss = textBox2.Text;
                card.phone = textBox3.Text;
                card.sex = comboBox1.Text;
                List.Add(card);
                ListViewItem item = new ListViewItem(textBox1.Text, comboBox1.SelectedIndex);
                item.SubItems.Add(textBox2.Text);
                item.SubItems.Add(textBox3.Text);
                item.SubItems.Add(comboBox1.Text);
                listView1.Items.Add(item);
                textBox1.Text = string.Empty;
                textBox2.Text = string.Empty;
                textBox3.Text = string.Empty;
                comboBox1.SelectedIndex = 0;
               
               
            }

            private void button2_Click(object sender, EventArgs e)
            {
                int current = 0;
                foreach (ListViewItem item in listView1.Items)
                {
                    if (item.Selected)
                    {
                        foreach (ADDR_CARD rem in List)
                        {
                            if (rem.name == item.Text)
                            {
                                current = List.IndexOf(rem);
                                List.RemoveAt(current);
                                break;
                            }
                        }
                        listView1.Items.Remove(item);
                    }
                }
                /*    MessageBox.Show(List.Count + "입니다");   */
                        
          
            }

            private void button3_Click(object sender, EventArgs e)
            {
              
                listView1.Sorting = SortOrder.Ascending;
                listView1.Sorting = SortOrder.None;
                List.Sort(new ListNameComparer());
            }

        
         
            
        }
    }
     
     public class ADDR_CARD
        {
            public string name;
            public string addrss;
            public string phone;
            public string sex;
        }

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

    =====다음 다음==================================================


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

    namespace R_PJW04
    {
        public partial class Form1 : Form
        {
            ArrayList List = new ArrayList();
            ADDR_CARD card;
            int index = 0;

            public Form1()
            {
                InitializeComponent();
            }

            private void button1_click(object sender, EventArgs e)
            {
                if (textBox1.Text == ""  || textBox2.Text == "" || textBox3.Text == "")
                {
                MessageBox.Show("정보를 넣어주세요", "오류");
                }
                else
                {
                   card = new ADDR_CARD();
                   card.name = textBox1.Text;
                   card.phone = textBox2.Text;
                   card.address = textBox3.Text;
                   List.Add(card);
                   textBox1.Text = string.Empty;
                   textBox2.Text = string.Empty;
                   textBox3.Text = string.Empty;
                   textBox1.Focus();
                }

            }

            private void button2_click(object sender, EventArgs e)
            {
                int search = 0;
                foreach (ADDR_CARD output in List)
                {
                    if (output.name == (string)textBox1.Text)
                    {
                        textBox1.Text = output.name;
                        textBox2.Text = output.phone;
                        textBox3.Text = output.address;
                        search = 1;
                    }
                }
                if(search == 0)
                    MessageBox.Show(textBox1.Text + "이(가) 없습니다.", "검색");
             
            }

            private void button3_Click(object sender, EventArgs e)
            {
                 int search = 0;
                 int current = 0;
               
                 foreach (ADDR_CARD rem in List)
                 {
                     if (rem.name == this.textBox1.Text)
                     {
                         current = List.IndexOf(rem);                  
                         List.RemoveAt(current);          
                         search = 1;
                         break;
                     }
                 }

                 if (search == 0)
                 {
                     MessageBox.Show(textBox1.Text + " 은(는) 명단에 없습니다.", "제거");
                 }
                 else if(List.Count != 0)
                 {
                     if (current == List.Count)
                     {
                         current = 0;
                     }
                     textBox1.Text = (string)((ADDR_CARD)List[current]).name;
                     textBox2.Text = (string)((ADDR_CARD)List[current]).phone;
                     textBox3.Text = (string)((ADDR_CARD)List[current]).address;
                 }
                 else
                 {
                     textBox1.Text = string.Empty;
                     textBox2.Text = string.Empty;
                     textBox3.Text = string.Empty;
                     MessageBox.Show("정보를넣어주세요");
                 }
            }

            private void button4_Click(object sender, EventArgs e)
            {

                if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
                {
                    MessageBox.Show("검색을 해주세요", "오류");
                }
                   
                else
                {
                    foreach (ADDR_CARD next in List)
                    {
                        if (next.name == textBox1.Text)
                        {
                            index = List.IndexOf(next);
                            index--;
                            break;
                        }
                    }
                    if (index == -1)
                    {
                        index = List.Count - 1;
                    }
                    textBox1.Text = (string)((ADDR_CARD)List[index]).name;
                    textBox2.Text = (string)((ADDR_CARD)List[index]).phone;
                    textBox3.Text = (string)((ADDR_CARD)List[index]).address;
                }
            }

            private void button5_Click(object sender, EventArgs e)
            {

                if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
                {
                    MessageBox.Show("검색을 해주세요", "오류");
                }

                else
                {
                    foreach (ADDR_CARD next in List)
                    {
                        if (next.name == textBox1.Text)
                        {
                            index = List.IndexOf(next);                  
                            index++;
                            break;
                        }
                    }
                    if (index == List.Count)
                    {
                        index = 0;
                    }
                    textBox1.Text = (string)((ADDR_CARD)List[index]).name;
                    textBox2.Text = (string)((ADDR_CARD)List[index]).phone;
                    textBox3.Text = (string)((ADDR_CARD)List[index]).address;
                   
                }
            }

            private void button6_Click(object sender, EventArgs e)
            {
                textBox1.Text = string.Empty;
                textBox2.Text = string.Empty;
                textBox3.Text = string.Empty;
            }

           
        }
    }

       

    2010년 10월 18일 월요일 오전 2:22