public void AllowSaveColWidth ( bool bFlag , string strXmlFile , string strListName ) { //加在这里是因为init()里面没起效果,隐藏列可以被拉开。ColumnWidthChanged加在这里可以被强制执行。 ColumnWidthChanged += new System.Windows.Forms.ColumnWidthChangedEventHandler(this.OnColumnWidthChanged); ColumnWidthChanging += new System.Windows.Forms.ColumnWidthChangingEventHandler(this.OnColWidthChanging); _bAllowSaveFldWidth = bFlag; _strXmlFile = strXmlFile; _strListName = strListName; if ( _strXmlFile.Trim () == "" || strListName.Trim() == "" ) _bAllowSaveFldWidth = false; }
public void Init () { this.View = System.Windows.Forms.View.Details; MultiSelect = false; //AllowOrder ( false ); //默不能排序。 AllowOrder ( true ); //默可以排序。 //设定排序器. ListViewItemSorter = _sorter; _sorter.Order = SortOrder.Ascending; //消息响应函数。 ColumnClick += new System.Windows.Forms.ColumnClickEventHandler ( this.OnColumnClick ); ColumnWidthChanging += new System.Windows.Forms.ColumnWidthChangingEventHandler ( this.OnColWidthChanging ); ItemMouseHover += new System.Windows.Forms.ListViewItemMouseHoverEventHandler ( this.OnItemMouseHover ); ColumnWidthChanged += new System.Windows.Forms.ColumnWidthChangedEventHandler ( this.OnColumnWidthChanged ); // SetStyle (); //RestoreColWidth (); // SetDefaultAllOrderType (); //SaveColW(); }