none
읭읭읭 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();
            }
            DataTable tbl;
            private void Form1_Load(object sender, EventArgs e)
            {
                tbl = new DataTable("hakjuk");

                DataColumn col = new DataColumn();
                col.DataType = Type.GetType("System.String");
                col.ColumnName = "Name";
                col.AllowDBNull = false;
                tbl.Columns.Add(col);

                col = new DataColumn();
                col.DataType = Type.GetType("System.Int32");
                col.ColumnName = "Age";
                col.AllowDBNull = false;
                tbl.Columns.Add(col);

                col = new DataColumn();
                col.DataType = Type.GetType("System.String");
                col.ColumnName = "State";
                col.AllowDBNull = false;
                tbl.Columns.Add(col);

                col = new DataColumn();
                col.DataType = Type.GetType("System.String");
                col.ColumnName = "HighSchool";
                col.AllowDBNull = false;
                tbl.Columns.Add(col);

                DataRow row = tbl.NewRow();
                row["Name"] = "박준영";
                row["Age"] = 24;
                row["State"] = "전라남도";
                row["HighSchool"] = "문태고";
                tbl.Rows.Add(row);

                dataGridView1.DataSource = tbl;
            }

            private void button1_Click(object sender, EventArgs e)
            {
                DataRow row = tbl.NewRow();
                row["Name"] = textBox1.Text;
                row["Age"] = Int32.Parse(textBox2.Text);
                row["State"] = textBox3.Text;
                row["HighSchool"] = textBox4.Text;
                tbl.Rows.Add(row);

                dataGridView1.DataSource = tbl;
            }

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

                view1.RowFilter = textBox5.Text;

                dataGridView2.DataSource = view1;
            }

        }
    }


    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    잉여 탭 컨트롤 입력창 잉여

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

            private void Form1_Load(object sender, EventArgs e)
            {
                oleDbConnection1.Open();
                oleDbDataAdapter1.Fill(dataSet11);
            }

            private void button1_Click(object sender, EventArgs e)
            {
                oleDbDataAdapter1.Fill(dataSet11);
            }

            private void button3_Click(object sender, EventArgs e)
            {
                try
                {
                    oleDbCommand1.Parameters[1].Value = textBox1.Text;
                    oleDbCommand1.Parameters[3].Value = int.Parse(textBox2.Text);
                    oleDbCommand1.Parameters[4].Value = textBox5.Text;
                    oleDbCommand1.Parameters[5].Value = textBox3.Text;
                    oleDbCommand1.Parameters[6].Value = textBox4.Text;

                    oleDbCommand1.ExecuteNonQuery();
                    textBox1.ResetText();
                    textBox2.ResetText();
                    textBox3.ResetText();
                    textBox4.ResetText();
                    textBox5.ResetText();
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

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

    2009년 12월 9일 수요일 오전 1:26