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

📄 gridstyleinfo.cs

📁 一个通用的数据库访问层
💻 CS
字号:
using System;
using System.Collections;
using System.Windows.Forms;

namespace YariSoft.DBCommander.Misc
{
	[Serializable]
	public class GridStyleInfo
	{
		#region Local Variables
		Hashtable styles = null;
		#endregion

		#region Properties
		#endregion

		#region Constructor/Destructor
		public GridStyleInfo()
		{
			this.styles = new Hashtable();
		}

		#endregion

		#region Public functions

		public void Clear ()
		{
			this.styles.Clear();
		}

		public Hashtable Add ( DataGridTableStyle style )
		{
			Hashtable columnsStyle = new Hashtable();
			foreach( DataGridColumnStyle columnStyle in style.GridColumnStyles ){
				columnsStyle.Add( columnStyle.MappingName, columnStyle.Width );
			}

			this.styles.Add( style.MappingName, columnsStyle );
			return columnsStyle;
		}

		public void Update ( DataGridTableStyle style )
		{
			Hashtable columnsStyle = ( Hashtable )this.styles[ style.MappingName ];
			if( columnsStyle == null ){
				columnsStyle = this.Add( style );
				return;
			}

			foreach( DataGridColumnStyle columnStyle in style.GridColumnStyles ){
				columnsStyle[ columnStyle.MappingName ] = columnStyle.Width;
			}
		}

		public void Update ( GridTableStylesCollection styles )
		{
			foreach( DataGridTableStyle style in styles ){
				this.Update( style );
			}
		}

		public bool SetStyleToGrid ( DataGridTableStyle style )
		{
			Hashtable columnsStyle = ( Hashtable )this.styles[ style.MappingName ];
			if( columnsStyle == null ){
				return false;
			}

			foreach( DataGridColumnStyle columnStyle in style.GridColumnStyles ){
				columnStyle.Width = ( int )columnsStyle[ columnStyle.MappingName ];
			}
			return true;
		}
		#endregion
	}
}

⌨️ 快捷键说明

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