⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ultragridform.cs

📁 TREEVIEW AND LISTVIEW IS USER
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using System.Data;
using System.Data.OracleClient;

using Infragistics.Win.UltraWinGrid;

namespace WinDemoOne
{
	/// <summary>
	/// UltraGridForm 的摘要说明。
	/// </summary>
	public class UltraGridForm : System.Windows.Forms.Form
	{
		private Infragistics.Win.UltraWinGrid.UltraGrid ugEmp;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		OracleDataAdapter adapter = null;

		public UltraGridForm()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance12 = new Infragistics.Win.Appearance();
			this.ugEmp = new Infragistics.Win.UltraWinGrid.UltraGrid();
			((System.ComponentModel.ISupportInitialize)(this.ugEmp)).BeginInit();
			this.SuspendLayout();
			// 
			// ugEmp
			// 
			this.ugEmp.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			appearance1.BackColor = System.Drawing.SystemColors.Window;
			appearance1.BorderColor = System.Drawing.SystemColors.InactiveCaption;
			this.ugEmp.DisplayLayout.Appearance = appearance1;
			this.ugEmp.DisplayLayout.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
			this.ugEmp.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.False;
			appearance2.BackColor = System.Drawing.SystemColors.ActiveBorder;
			appearance2.BackColor2 = System.Drawing.SystemColors.ControlDark;
			appearance2.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
			appearance2.BorderColor = System.Drawing.SystemColors.Window;
			this.ugEmp.DisplayLayout.GroupByBox.Appearance = appearance2;
			appearance3.ForeColor = System.Drawing.SystemColors.GrayText;
			this.ugEmp.DisplayLayout.GroupByBox.BandLabelAppearance = appearance3;
			this.ugEmp.DisplayLayout.GroupByBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
			appearance4.BackColor = System.Drawing.SystemColors.ControlLightLight;
			appearance4.BackColor2 = System.Drawing.SystemColors.Control;
			appearance4.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
			appearance4.ForeColor = System.Drawing.SystemColors.GrayText;
			this.ugEmp.DisplayLayout.GroupByBox.PromptAppearance = appearance4;
			this.ugEmp.DisplayLayout.MaxColScrollRegions = 1;
			this.ugEmp.DisplayLayout.MaxRowScrollRegions = 1;
			appearance5.BackColor = System.Drawing.SystemColors.Window;
			appearance5.ForeColor = System.Drawing.SystemColors.ControlText;
			this.ugEmp.DisplayLayout.Override.ActiveCellAppearance = appearance5;
			appearance6.BackColor = System.Drawing.SystemColors.Highlight;
			appearance6.ForeColor = System.Drawing.SystemColors.HighlightText;
			this.ugEmp.DisplayLayout.Override.ActiveRowAppearance = appearance6;
			this.ugEmp.DisplayLayout.Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.Dotted;
			this.ugEmp.DisplayLayout.Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Dotted;
			appearance7.BackColor = System.Drawing.SystemColors.Window;
			this.ugEmp.DisplayLayout.Override.CardAreaAppearance = appearance7;
			appearance8.BorderColor = System.Drawing.Color.Silver;
			appearance8.TextTrimming = Infragistics.Win.TextTrimming.EllipsisCharacter;
			this.ugEmp.DisplayLayout.Override.CellAppearance = appearance8;
			this.ugEmp.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.EditAndSelectText;
			this.ugEmp.DisplayLayout.Override.CellPadding = 0;
			appearance9.BackColor = System.Drawing.SystemColors.Control;
			appearance9.BackColor2 = System.Drawing.SystemColors.ControlDark;
			appearance9.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
			appearance9.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
			appearance9.BorderColor = System.Drawing.SystemColors.Window;
			this.ugEmp.DisplayLayout.Override.GroupByRowAppearance = appearance9;
			appearance10.TextHAlign = Infragistics.Win.HAlign.Left;
			this.ugEmp.DisplayLayout.Override.HeaderAppearance = appearance10;
			this.ugEmp.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti;
			this.ugEmp.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
			appearance11.BackColor = System.Drawing.SystemColors.Window;
			appearance11.BorderColor = System.Drawing.Color.Silver;
			this.ugEmp.DisplayLayout.Override.RowAppearance = appearance11;
			this.ugEmp.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.False;
			appearance12.BackColor = System.Drawing.SystemColors.ControlLight;
			this.ugEmp.DisplayLayout.Override.TemplateAddRowAppearance = appearance12;
			this.ugEmp.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
			this.ugEmp.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
			this.ugEmp.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy;
			this.ugEmp.Location = new System.Drawing.Point(8, 8);
			this.ugEmp.Name = "ugEmp";
			this.ugEmp.Size = new System.Drawing.Size(616, 352);
			this.ugEmp.TabIndex = 0;
			this.ugEmp.Text = "ultraGrid1";
			// 
			// UltraGridForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(632, 362);
			this.Controls.Add(this.ugEmp);
			this.Name = "UltraGridForm";
			this.Text = "UltraGridForm";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Load += new System.EventHandler(this.UltraGridForm_Load);
			this.Closed += new System.EventHandler(this.UltraGridForm_Closed);
			((System.ComponentModel.ISupportInitialize)(this.ugEmp)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void UltraGridForm_Load(object sender, System.EventArgs e)
		{
			string connectionString = "user id=scott;data source=oralsea;password=tiger";
			string sql = "select * from emp";
			adapter = new OracleDataAdapter(sql, connectionString);

			OracleCommandBuilder builder = new OracleCommandBuilder(adapter);
			adapter.InsertCommand = builder.GetInsertCommand();
			adapter.UpdateCommand = builder.GetUpdateCommand();
			adapter.DeleteCommand = builder.GetDeleteCommand();

			DataTable dt = new DataTable();
			adapter.Fill(dt);

			ugEmp.DataSource = dt;


			//构造下拉框
			ugEmp.DisplayLayout.Bands[0].Columns["Job"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown;
			
			ugEmp.DisplayLayout.ValueLists.Add("job");
			ugEmp.DisplayLayout.ValueLists["job"].ValueListItems.Add("CLERT", "收银员");
			ugEmp.DisplayLayout.ValueLists["job"].ValueListItems.Add("MANAGER", "收银员");
			ugEmp.DisplayLayout.ValueLists["job"].ValueListItems.Add("ANALYST", "系统分析员");
			ugEmp.DisplayLayout.ValueLists["job"].ValueListItems.Add("SALESMAN", "销售员");
			
			ugEmp.DisplayLayout.Bands[0].Columns["Job"].ValueList = ugEmp.DisplayLayout.ValueLists["job"];



		}

		private void UltraGridForm_Closed(object sender, System.EventArgs e)
		{
			adapter.Update((DataTable)ugEmp.DataSource);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -