none
예문4 RRS feed

  • 질문

  •  

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

    namespace KBJ_16
    {
        public partial class Form1 : Form
        {
            DataTable tb1;
            public Form1()
            {
                InitializeComponent();
                tb1 = new DataTable("info");
                DataColumn column;

                column = new DataColumn();
                column.DataType = Type.GetType("System.String");
                column.ColumnName = "이름";
                column.AllowDBNull = false;
                tb1.Columns.Add(column);
               
                column = new DataColumn();
                column.DataType = Type.GetType("System.Int32");
                column.ColumnName = "나이";
                column.AllowDBNull = false;
                tb1.Columns.Add(column);

                column = new DataColumn();
                column.DataType = Type.GetType("System.String");
                column.ColumnName = "출신도";
                column.AllowDBNull = false;
                tb1.Columns.Add(column);

                column = new DataColumn();
                column.DataType = Type.GetType("System.String");
                column.ColumnName = "출신고교";
                column.AllowDBNull = false;
                tb1.Columns.Add(column);
            }

            private void button1_Click(object sender, EventArgs e)
            {
                DataRow row;
                row = tb1.NewRow();
                row["이름"] = textBox1.Text;
                row["나이"] = int.Parse(textBox2.Text);
                row["출신도"] = textBox3.Text;
                row["출신고교"] = textBox4.Text;
                tb1.Rows.Add(row);
                dataGridView1.DataSource = tb1;
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
            }

            private void button2_Click(object sender, EventArgs e)
            {
                DataView view = new DataView(this.tb1);

                view.RowFilter = textBox5.Text;
                dataGridView2.DataSource = view;
            }

        }
    }

    2008년 12월 9일 화요일 오전 2:56

모든 응답

  • 0001    using System;
    0002    using System.Collections.Generic;
    0003    using System.ComponentModel;
    0004    using System.Data;
    0005    using System.Drawing;
    0006    using System.Text;
    0007    using System.Windows.Forms;
    0008    using System.Data.OleDb;
    0009    
    0010    namespace KBJ_16
    0011    {
    0012        public partial class Form1 : Form
    0013        {
    0014            DataTable tb1;
    0015            public Form1()
    0016            {
    0017                InitializeComponent();
    0018                tb1 = new DataTable("info");
    0019                DataColumn column;
    0020    
    0021                column = new DataColumn();
    0022                column.DataType = Type.GetType("System.String");
    0023                column.ColumnName = "이름";
    0024                column.AllowDBNull = false;
    0025                tb1.Columns.Add(column);
    0026    
    0027                column = new DataColumn();
    0028                column.DataType = Type.GetType("System.Int32");
    0029                column.ColumnName = "나이";
    0030                column.AllowDBNull = false;
    0031                tb1.Columns.Add(column);
    0032    
    0033                column = new DataColumn();
    0034                column.DataType = Type.GetType("System.String");
    0035                column.ColumnName = "출신도";
    0036                column.AllowDBNull = false;
    0037                tb1.Columns.Add(column);
    0038    
    0039                column = new DataColumn();
    0040                column.DataType = Type.GetType("System.String");
    0041                column.ColumnName = "출신고교";
    0042                column.AllowDBNull = false;
    0043                tb1.Columns.Add(column);
    0044            }
    0045    
    0046            private void button1_Click(object sender, EventArgs e)
    0047            {
    0048                DataRow row;
    0049                row = tb1.NewRow();
    0050                row["이름"] = textBox1.Text;
    0051                row["나이"] = int.Parse(textBox2.Text);
    0052                row["출신도"] = textBox3.Text;
    0053                row["출신고교"] = textBox4.Text;
    0054                tb1.Rows.Add(row);
    0055                dataGridView1.DataSource = tb1;
    0056                textBox1.Text = "";
    0057                textBox2.Text = "";
    0058                textBox3.Text = "";
    0059                textBox4.Text = "";
    0060            }
    0061    
    0062            private void button2_Click(object sender, EventArgs e)
    0063            {
    0064                DataView view = new DataView(this.tb1);
    0065    
    0066                view.RowFilter = textBox5.Text;
    0067                dataGridView2.DataSource = view;
    0068            }
    0069        }
    0070    }
    0071    
    2009년 11월 4일 수요일 오후 5:00