using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.Data.SqlClient;namespace WindowsApplication2...{ /**//// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form ...{ private System.Windows.Forms.DataGrid dg1; private System.Windows.Forms.MainMenu mainMenu1; private System.Data.SqlClient.SqlConnection cn; private SqlCommand cmd; private SqlDataAdapter da; private DataSet ds; /**//// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public Form1() ...{ // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // cn=new SqlConnection("server=xx007;uid=sa;pwd=sa;database=pubs"); cn.Open(); cmd.Connection=cn; cmd.CommandText="select * from jobs"; } /**//// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) ...{ if( disposing ) ...{ if (components != null) ...{ components.Dispose(); } } base.Dispose( disposing ); } Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码 /**//// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() ...{ this.dg1 = new System.Windows.Forms.DataGrid(); this.mainMenu1 = new System.Windows.Forms.MainMenu(); ((System.ComponentModel.ISupportInitialize)(this.dg1)).BeginInit(); this.SuspendLayout(); // // dg1 // this.dg1.DataMember = ""; this.dg1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dg1.Location = new System.Drawing.Point(0, 0); this.dg1.Name = "dg1"; this.dg1.Size = new System.Drawing.Size(544, 296); this.dg1.TabIndex = 1; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(552, 301); this.Controls.Add(this.dg1); this.Menu = this.mainMenu1; this.Name = "Form1"; this.Text = "Form1"; ((System.ComponentModel.ISupportInitialize)(this.dg1)).EndInit(); this.ResumeLayout(false); } #endregion /**//// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() ...{ Application.Run(new Form1()); } }}