frmDisplay.cs

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

        private void frmDisplay_Load(object sender, EventArgs e)
        {
            this.dataGridView1.RowHeadersVisible = false;
            this.dataGridView1.AllowUserToAddRows = false;
            this.dataGridView1.ReadOnly = true;
            this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            // 禁止用户改变DataGridView1的所有列的列宽  
            this.dataGridView1.AllowUserToResizeColumns = false;  
            //禁止用户改变DataGridView1の所有行的行高  
            this.dataGridView1.AllowUserToResizeRows = false;

            this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
           

            this.comboBox1.SelectedIndex = 0;
            string sql = "select TNO as 教师编号,TNAME as 教师姓名,TSEX as 性别 from TEACHERS";
            DataTable table = SqlManage.TableSelect(sql);
            this.dataGridView1.DataSource = table;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string sql = "";
            switch (this.comboBox1.SelectedIndex)
            {
                case 0:
                    sql = "select TNO as 教师编号,TNAME as 教师姓名,TSEX as 性别 from TEACHERS";
                    break;
                case 1:
                    sql = "select CNO as 课程标号,CNAME as 课程名,CTIME as 学时 from COURSES";
                    break;
                case 2:
                    sql = "select TNO as 教师编号,CNO as 课程标号,WYEAR as 年份,WSTAGE as 学期 from WORKS";
                    break;
                default:
                    break;
            }
            DataTable table = SqlManage.TableSelect(sql);
            this.dataGridView1.DataSource = table;
        }

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

 

posted on 2017-03-16 16:03  Cody_Rainfall  阅读(192)  评论(0)    收藏  举报

导航