none
microsoft swap RRS feed

  • 질문

  • 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 Form1 : Form
        {
           
           
            public Form1()
            {
                InitializeComponent();
            }

            private void 취소ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                textBox1.Undo();
            }

            private void 복사ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                textBox1.Copy();
            }

            private void 붙이기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                textBox1.Paste();
            }

            private void 자르기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                textBox1.Cut();
            }

            private void 모두선택ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                textBox1.SelectAll();
            }

            private void 찾아바꾸기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                //모달리스
                Form2 dig = new Form2(this);
                dig.Show();
            }
        }
    }

    2009년 10월 13일 화요일 오후 6:16

모든 응답

  • 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;
    using System.Runtime.Serialization.Formatters.Binary;
    using System.IO;

    namespace   ADD_CARD    Save
    {
        public partial class Form1 : Form
        {
            [Serializable]
            class ADD_CARD
            {
                public string name;
                public string phone;
                public string addr;
            }
            public Form1()
            {
                InitializeComponent();
            }
           
            ArrayList ary = new ArrayList();

            private void button1_Click_1(object sender, EventArgs e)
            {
                 ADD_CARD item = new ADD_CARD();
                item.name = textBox1.Text;
                item.phone = textBox2.Text;
                item.addr = textBox3.Text;
                ary.Add(item);
                textBox1.Clear();
                textBox2.Clear();
                textBox3.Clear();
               
            }

            private void button2_Click_1(object sender, EventArgs e)
            {
                foreach (ADD_CARD d in ary)
                {
                    if (d.name == textBox1.Text)
                    {
                        textBox1.Text = d.name;
                        textBox2.Text = d.phone;
                        textBox3.Text = d.addr;
                    }
                }
            }
           
            int i = 0;
            private void button3_Click_1(object sender, EventArgs e)
            {
                try
                {
                    ADD_CARD card1 = new ADD_CARD();
                    card1 = (ADD_CARD)ary[i];
                    textBox1.Text = card1.name;
                    textBox2.Text = card1.phone;
                    textBox3.Text = card1.addr;
                    i++;
                }
                catch
                {
                    i = 0;
                    ADD_CARD card1 = new ADD_CARD();
                    card1 = (ADD_CARD)ary[i];
                    textBox1.Text = card1.name;
                    textBox2.Text = card1.phone;
                    textBox3.Text = card1.addr;
                    i++;
                }
            }

            private void 열기ToolStripMenuItem_Click_1(object sender, EventArgs e)
            {
                openFileDialog1.ShowDialog();
                FileStream fs1 = new FileStream(openFileDialog1.FileName, FileMode.Open);
                BinaryFormatter bf1 = new BinaryFormatter();
                ary = (ArrayList)bf1.Deserialize(fs1);
                Form1.ActiveForm.Text = openFileDialog1.FileName;
            }

            private void 저장ToolStripMenuItem_Click_1(object sender, EventArgs e)
            {
                saveFileDialog1.ShowDialog();
                FileStream fs = new FileStream(saveFileDialog1.FileName, FileMode.Create);
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(fs, ary);
                fs.Close();
            }

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

          

        }
    }

     

    2009년 10월 13일 화요일 오후 6:24
  • 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;
    using System.IO;

    namespace    디렉토리 파일 읽기
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void 열기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                openFileDialog1.ShowDialog();
                DirectoryInfo[] dir;
                DirectoryInfo dinfo = new DirectoryInfo(openFileDialog1.FileName);
                FileInfo finfo = new FileInfo(openFileDialog1.FileName);

                dinfo = finfo.Directory;
                dir = dinfo.GetDirectories();

                foreach (DirectoryInfo d in dir)
                {
                    listBox1.Items.Add(d.Name.ToString());
                }

                FileInfo[] files = dinfo.GetFiles();

                foreach (FileInfo f in files)
                {
                    listBox2.Items.Add(f.Name.ToString());
                }
                    Form1.ActiveForm.Text = finfo.FullName;
            }
           
               
        }
    }

    2009년 10월 13일 화요일 오후 6:50
  • 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 Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
            {
                this.BackColor = Color.FromArgb(hScrollBar1.Value, hScrollBar2.Value,hScrollBar3.Value);
            }

            private void hScrollBar2_Scroll(object sender, ScrollEventArgs e)
            {
                this.BackColor = Color.FromArgb(hScrollBar1.Value, hScrollBar2.Value,hScrollBar3.Value);
            }

            private void hScrollBar3_Scroll(object sender, ScrollEventArgs e)
            {
                this.BackColor = Color.FromArgb(hScrollBar1.Value, hScrollBar2.Value,hScrollBar3.Value);
            }
        }
    }

    2009년 10월 13일 화요일 오후 7:03
  • namespace 찾기
    {
        public partial class Form2 : Form
        {
            public Form1 dlg;

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

            private void button1_Click(object sender, EventArgs e)
            {
                string str = dlg.textBox1.Text;

                if (str.Contains(textBox1.Text))
                {
                    int i = str.IndexOf(textBox1.Text, 0);

                    if (i != -1)
                    {
                        int j = textBox1.Text.Length;

                        str = str.Remove(i, j);
                        str = str.Insert(i, textBox2.Text);
                        dlg.textBox1.Text = str;
                    }
                }
            }

            private void button4_Click(object sender, EventArgs e)
            {
                this.Close();
            }

            private void button3_Click(object sender, EventArgs e)
            {
                string str = dlg.textBox1.Text;
                if (str.Contains(textBox1.Text))
                {
                    str = str.Replace(textBox1.Text, textBox2.Text);
                    dlg.textBox1.Text = str;
                }
               
            }

            private void button2_Click(object sender, EventArgs e)
            {
                string str = dlg.textBox1.Text;
                if(str.Contains(textBox1.Text))
                {
                    StartP = str.IndexOf(textBox1.Text, StartP);

                    if (StartP != -1)
                    {
                        int b = textBox1.Text.Length;
                        dlg.textBox1.Select(StartP, b);
                        dlg.textBox1.Focus();
                        StartP++;
                    }

                    else
                    {
                        MessageBox.Show("찾을 문자가없습니다");
                        StartP = 0;
                    }
                }
              
            }
        }
    }

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

    namespace 파일탐색기
    {
        public partial class Form1 : Form
        {
            public DirectoryInfo dinfo;
            public DirectoryInfo[] dir;
            public int count;
            ArrayList ar=new ArrayList();
            string adress;      
     
            public Form1()
            {
                InitializeComponent();
                count = 0;
            }
            public void make_list()
            {

                listView1.Items.Clear();

                ListViewItem item = new ListViewItem("..");
                item.SubItems.Add("");
                item.SubItems.Add("");
                item.SubItems.Add("");
                listView1.Items.Add(item);
                dir = dinfo.GetDirectories();
                count = dir.Length + 1;
                foreach (DirectoryInfo d in dir)
                {
                    ListViewItem item1 = new ListViewItem(d.Name.ToString(), 0);
                    item1.SubItems.Add(d.Attributes.ToString());
                    item1.SubItems.Add("");
                    item1.SubItems.Add(d.CreationTime.ToString());
                    listView1.Items.Add(item1);
                }
                FileInfo[] file = dinfo.GetFiles();
                foreach (FileInfo f in file)
                {
                    ListViewItem item2 = new ListViewItem(f.Name.ToString(), 1);
                    item2.SubItems.Add(f.Attributes.ToString());
                    item2.SubItems.Add(f.Length.ToString());
                    item2.SubItems.Add(f.CreationTime.ToString());
                    listView1.Items.Add(item2);
                }
                Text = dinfo.FullName.ToString();
               
            }


            private void 열기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                openFileDialog1.ShowDialog();
                dinfo = new DirectoryInfo(openFileDialog1.FileName);
                dinfo = dinfo.Parent;

                make_list();
            }

            private void listView1_Click(object sender, EventArgs e)
            {
                int index = listView1.FocusedItem.Index;
                if (index >= count)
                {
                   
                    return;
                }
                else if (index != 0)
                    dinfo = dir[index - 1];
                else
                {
                    if (dinfo.Parent == null)
                    {
                        MessageBox.Show("루트디렉토리입니다.");
                        return;
                    }
                   
                    dinfo = dinfo.Parent;
                }
                make_list();  
            }

            private void 파일복사하기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                FileInfo[] file = dinfo.GetFiles();
                ar.Clear();
               
                for(int i=0;i<listView1.SelectedItems.Count;i++)
                {
                    foreach (FileInfo f in file)
                    {
                        if(listView1.SelectedItems[i].Text==f.Name)
                        {
                            adress = f.FullName.ToString();
                            ar.Add(f.Name.ToString());                       
                        }
                    }
                }   
            }

            private void 붙이기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                FileInfo[] file = dinfo.GetFiles();
                string w = @"\";
                int copy_count = 0;
                foreach (string s in ar)
                {
                    for (int i = 0; i < file.Length; i++)
                    {
                        if (file[i].Name == s)
                        {
                            copy_count++;
                            MessageBox.Show(s+" 파일은 이미 존재합니다.");
                        }
                    }
                    if (copy_count == 0)
                    {
                        File.Copy(@adress, @Text + w + s);
                    }                   
                }
                listView1.Items.Clear();
                make_list();           
            }

            private void 파일삭제ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                FileInfo[] file = dinfo.GetFiles();
               
                for (int i = 0; i < listView1.SelectedItems.Count; i++)
                {
                    foreach (FileInfo f in file)
                    {
                        if (listView1.SelectedItems[i].Text == f.Name)
                        {
                            f.Delete();
                           
                        }
                    }
                }
                listView1.Items.Clear();
                make_list(); 
            }

            private void 끝내기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Close();
            }
        }

    }

    2009년 10월 14일 수요일 오전 4:18