当前位置:编程学习 > C#/ASP.NET >>

关于在DataGrid里添加ComboBox(一)

答案:这段代码我没整理过,希望哪位整理一下重新贴上来

using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.Globalization;
using System.Windows.Forms;
using System.ComponentModel;
using System.Data.SqlClient;

namespace ComboBoxInDataGrid
{
    public class Form2:System.Windows.Forms.Form
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private SqlDataAdapter sqlDA;
        private SqlCommand sqlSelectStudent;
        private SqlCommand sqlInsertStudent;
        private SqlCommand sqlUpdateStudent;
        private SqlCommand sqlDeleteStudent;
        private System.ComponentModel.Container components = null;
        private string StrSQL;
        private SqlConnection sqlConn;
        private DataSet _StudentDS;
        private DataTable _CourseDT;
        private DataGridTableStyle GridTableStyle;
        private System.Windows.Forms.Button btnUpdate;
        private System.Windows.Forms.Button btnMoveFirst;
        private System.Windows.Forms.Button btnMovePrevious;
        private System.Windows.Forms.Button btnMoveNext;
        private System.Windows.Forms.Button btnMoveLast;
        private System.Windows.Forms.DataGrid dataGrid1;
        private System.Windows.Forms.Label label1;
        private CurrencyManager objStudentCM;
        public Form2()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }
    #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.sqlUpdateStudent = new System.Data.SqlClient.SqlCommand();
            this.sqlConn = new System.Data.SqlClient.SqlConnection();
            this.sqlDA = new System.Data.SqlClient.SqlDataAdapter();
            this.sqlDeleteStudent = new System.Data.SqlClient.SqlCommand();
            this.sqlInsertStudent = new System.Data.SqlClient.SqlCommand();
            this.sqlSelectStudent = new System.Data.SqlClient.SqlCommand();
            this.btnMoveLast = new System.Windows.Forms.Button();
            this.dataGrid1 = new System.Windows.Forms.DataGrid();
            this.btnUpdate = new System.Windows.Forms.Button();
            this.btnMoveNext = new System.Windows.Forms.Button();
            this.btnMoveFirst = new System.Windows.Forms.Button();
            this.btnMovePrevious = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
            this.SuspendLayout();
            //
            // sqlUpdateStudent
            //
            this.sqlUpdateStudent.CommandText = @"UPDATE Student SET SNo = @SNo, SName = @SName, Course = @Course WHERE (SNo = @Original_SNo) AND (Course = @Original_Course OR @Original_Course1 IS NULL AND Course IS NULL) AND (SName = @Original_SName OR @Original_SName1 IS NULL AND SName IS NULL); SELECT SNo, SName, Course FROM Student WHERE (SNo = @Select_SNo)";
            this.sqlUpdateStudent.Connection = this.sqlConn;
            this.sqlUpdateStudent.Parameters.Add(new System.Data.SqlClient.SqlParameter("@SNo",

上一个:vb.net中字符串方法的使用
下一个:自定义按钮(转)

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,