gridstyleinfo.cs
来自「一个通用的数据库访问层」· CS 代码 · 共 78 行
CS
78 行
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 + =
减小字号Ctrl + -
显示快捷键?