private void SaveCustomizeColumnGridControl() { STColumnsController columnsController = new STColumnsController(); if (Screen.ScreenID > 0) { columnsController.DeleteByScreenIDAndControlName(Screen.ScreenID, this.Name); } foreach (GridColumn column in (CollectionBase)((ColumnView)this.ViewCollection[0]).Columns) { if (column.Visible) { columnsController.CreateObject((BusinessObject) new STColumnsInfo() { FK_STScreenID = Screen.ScreenID, STColumnFieldName = column.FieldName, STColumnControlName = this.Name, STColumnName = column.Name, STColumnWidth = column.Width, STColumnVisibleIndex = column.VisibleIndex }); } } int num = (int)MessageBox.Show("Lưu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }
protected virtual void InitGridColumnsVisibleIndex(GridView gridView) { STColumnsController objColumnsController = new STColumnsController(); List <STColumnsInfo> columns = objColumnsController.GetColumnsByScreenIDAndControlName(Screen.ScreenID, this.Name); if (columns.Count() > 0) { columns.ForEach(o => { if (gridView.Columns[o.STColumnFieldName] != null) { gridView.Columns[o.STColumnFieldName].VisibleIndex = o.STColumnVisibleIndex; gridView.Columns[o.STColumnFieldName].Width = o.STColumnWidth; } }); } else { this.InitDefaultGridColumnsVisibleIndex(gridView); } }