public void InitCol(string[] arrCol, LP_Temple lp) { m_ColName = arrCol; DataTable ds = new DataTable(); string[] arrColtype = lp.ComBoxItem.Split('|'); for (int i = 0; i < arrCol.Length; i++) { if (arrCol[i].ToString() == "") continue; if (arrColtype[i].IndexOf("RepositoryItemCalcEdit") > -1 || arrColtype[i].IndexOf("RepositoryItemSpinEdit") > -1) { ds.Columns.Add(arrCol[i], typeof(double)); } else if (arrColtype[i].IndexOf("RepositoryItemDateEdit") > -1) { ds.Columns.Add(arrCol[i], typeof(DateTime)); } else { ds.Columns.Add(arrCol[i], typeof(string)); } ds.Columns[i].Caption = arrCol[i]; } try { gridControl1.DataSource = ds; } catch (Exception err) { } DevExpress.XtraGrid.Views.Grid.GridView grid = gridView1; grid.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.True; grid.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.True; grid.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom; grid.OptionsView.ShowGroupPanel = false; string[] comItem = SelectorHelper.ToDBC(lp.ComBoxItem).Split('|'); ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit(); for (int i = 0; i < grid.Columns.Count; i++) { if (grid.Columns[i].FieldName == "序号" || grid.Columns[i].FieldName == "月份" || grid.Columns[i].FieldName == "季度") { grid.Columns[i].MinWidth = 20; } Regex r1 = new Regex(@"(?<=" + i + ":).*?(?=])"); string strcom = r1.Match(comItem[i]).Value; if (strcom.IndexOf("RepositoryItemDateEdit") > -1) { r1 = new Regex(@"(?<=:).*"); DevExpress.XtraEditors.Repository.RepositoryItemDateEdit date = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); if (r1.Match(strcom).Value != "") { date.Properties.EditMask = r1.Match(strcom).Value; date.Mask.UseMaskAsDisplayFormat = true; if (r1.Match(strcom).Value.ToLower().IndexOf("hh") > -1) { date.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True; date.VistaEditTime = DevExpress.Utils.DefaultBoolean.True; } } grid.Columns[i].ColumnEdit = date; grid.Columns[i].DisplayFormat.FormatString = date.Properties.EditMask; grid.Columns[i].ColumnEdit.EditFormat.FormatString = date.Properties.EditMask; } else if (strcom.IndexOf("RepositoryItemCalcEdit") > -1) { r1 = new Regex(@"(?<=:).*"); DevExpress.XtraEditors.Repository.RepositoryItemCalcEdit date = new DevExpress.XtraEditors.Repository.RepositoryItemCalcEdit(); if (r1.Match(strcom).Value != "") date.Properties.EditMask = r1.Match(strcom).Value; grid.Columns[i].ColumnEdit = date; } else if (strcom.IndexOf("RepositoryItemSpinEdit") > -1) { r1 = new Regex(@"(?<=:).*"); DevExpress.XtraEditors.Repository.RepositoryItemSpinEdit lue1 = new DevExpress.XtraEditors.Repository.RepositoryItemSpinEdit(); ((System.ComponentModel.ISupportInitialize)(lue1)).BeginInit(); if (r1.Match(strcom).Value != "") { if (r1.Match(strcom).Value.IndexOf("p") > -1) { lue1.Increment = (decimal)0.0001; lue1.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; } else if (r1.Match(strcom).Value.IndexOf(".") > -1) { Regex r2 = new Regex(@"(?<=\.).*"); lue1.Increment = (decimal)Math.Pow(0.1, r2.Match(strcom).Value.Length / 2); lue1.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; } lue1.Name = ("lue1" + i.ToString()); lue1.Properties.EditMask = r1.Match(strcom).Value; lue1.DisplayFormat.FormatString = r1.Match(strcom).Value; lue1.Properties.DisplayFormat.FormatString = r1.Match(strcom).Value; lue1.EditMask = r1.Match(strcom).Value; } gridView1.Columns[i].ColumnEdit = lue1; //if (lue1.Properties.EditMask.IndexOf("p") > -1 || lue1.Properties.EditMask.IndexOf("%") > -1) { gridView1.Columns[i].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridView1.Columns[i].DisplayFormat.FormatString = lue1.Properties.EditMask.ToString(); } ((System.ComponentModel.ISupportInitialize)(lue1)).EndInit(); } else if (strcom.IndexOf("RepositoryItemCheckedComboBoxEdit") > -1) { DevExpress.XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit lue1 = new DevExpress.XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit(); lue1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; grid.Columns[i].ColumnEdit = lue1; //colctrllist.Add(lue1); } else { DevExpress.XtraEditors.Repository.RepositoryItemComboBox lue1 = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox(); lue1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; grid.Columns[i].ColumnEdit = lue1; colctrllist.Add(lue1); } } ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit(); gridView1.BestFitColumns(); }
protected override GridView InitializeGridView() { GridView gridView = base.InitializeGridView(); gridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom; repositoryItemDateEdit = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); // repositoryItemDateEdit repositoryItemDateEdit.AutoHeight = false; repositoryItemDateEdit.DisplayFormat.FormatString = "HH:mm:ss"; repositoryItemDateEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; repositoryItemDateEdit.Mask.EditMask = "HH:mm:ss"; repositoryItemDateEdit.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; repositoryItemDateEdit.Name = "repositoryItemDateEdit1"; GridColumn column = gridView.Columns["HRTimeKeeperCompleteTimeCheck"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["HRTimeKeeperCompleteInOutMode"]; if (column != null) { column.OptionsColumn.AllowEdit = true; //column.ColumnEdit = repositoryItemDateEdit; } gridView.KeyUp += new KeyEventHandler(GridView_KeyUp); gridView.RowStyle += new RowStyleEventHandler(gridView_RowStyle); gridView.CustomColumnDisplayText += new CustomColumnDisplayTextEventHandler(gridView_CustomColumnDisplayText); return(gridView); }
public override void InitializeControl() { base.InitializeControl(); DevExpress.XtraGrid.Views.Grid.GridView gridView = base.InitializeGridView(); gridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom; gridView.OptionsView.ShowFooter = true; GridColumn column = gridView.Columns["HRTimeKeeperDate"]; if (column != null) { column.Group(); } column = null; column = gridView.Columns["FK_HRMachineTimeKeeperID"]; if (column != null) { //column.Group(); } // repositoryItemDateEdit repositoryItemDateEdit = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); repositoryItemDateEdit.AutoHeight = false; repositoryItemDateEdit.DisplayFormat.FormatString = "HH:mm:ss"; repositoryItemDateEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; repositoryItemDateEdit.Mask.EditMask = "HH:mm:ss"; repositoryItemDateEdit.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; repositoryItemDateEdit.Name = "repositoryItemDateEdit1"; column = gridView.Columns["HRTimeKeeperTimeIn"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["HRTimeKeeperTimeOut"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } }
protected override GridView InitializeGridView() { GridView gridView = base.InitializeGridView(); gridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom; gridView.ShowFilterPopupListBox += new DevExpress.XtraGrid.Views.Grid.FilterPopupListBoxEventHandler(this.gridView1_ShowFilterPopupListBox); repositoryItemDateEdit = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); // repositoryItemDateEdit repositoryItemDateEdit.AutoHeight = false; repositoryItemDateEdit.DisplayFormat.FormatString = "HH:mm:ss"; repositoryItemDateEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; repositoryItemDateEdit.Mask.EditMask = "HH:mm:ss"; repositoryItemDateEdit.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; repositoryItemDateEdit.Name = "repositoryItemDateEdit1"; GridColumn column = gridView.Columns["HRTimeKeeperCompleteTimeCheck"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["HRTimeKeeperCompleteInOutMode"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["HRTimeKeeperCompleteDate"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } gridView.InvalidRowException += new DevExpress.XtraGrid.Views.Base.InvalidRowExceptionEventHandler(gridView_InvalidRowException); gridView.KeyUp += new KeyEventHandler(GridView_KeyUp); gridView.RowStyle += new RowStyleEventHandler(gridView_RowStyle); gridView.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(gridView_CellValueChanged); return(gridView); }
static public void Column_SetNumber(ref GridView view, int column_index, string valueformat) { if (column_index >= 0 && column_index < view.Columns.Count) { #region Creating and Setting Repository Editor DevExpress.XtraEditors.Repository.RepositoryItemDateEdit re = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); re.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; re.DisplayFormat.FormatString = valueformat; re.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric; re.EditFormat.FormatString = valueformat; #endregion #region Setting Values to Column if (view.Columns[column_index].ColumnEdit != null) { view.GridControl.RepositoryItems.Remove(view.Columns[column_index].ColumnEdit); view.Columns[column_index].ColumnEdit.Dispose(); view.Columns[column_index].ColumnEdit = null; } view.Columns[column_index].ColumnEdit = re; view.GridControl.RepositoryItems.Add(re); #endregion } }
protected override GridView InitializeGridView() { GridView gridView = base.InitializeGridView(); gridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom; repositoryItemDateEdit = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); // repositoryItemDateEdit repositoryItemDateEdit.AutoHeight = false; repositoryItemDateEdit.DisplayFormat.FormatString = "HH:mm:ss"; repositoryItemDateEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; repositoryItemDateEdit.EditFormat.FormatString = "HH:mm:ss"; repositoryItemDateEdit.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime; repositoryItemDateEdit.Mask.EditMask = "HH:mm:ss"; repositoryItemDateEdit.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; repositoryItemDateEdit.Name = "repositoryItemDateEdit1"; GridColumn column = gridView.Columns["HROTFactorValue"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["HROTFactorFromTime"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["HROTFactorType"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["FK_ADOTFactorID"]; if (column != null) { column.OptionsColumn.AllowEdit = true; RepositoryItemLookUpEdit repositoryItemLookUpEdit = new RepositoryItemLookUpEdit(); repositoryItemLookUpEdit.DisplayMember = "ADOTFactorName"; repositoryItemLookUpEdit.ValueMember = "ADOTFactorID"; repositoryItemLookUpEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; repositoryItemLookUpEdit.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoFilter; repositoryItemLookUpEdit.NullText = string.Empty; repositoryItemLookUpEdit.Columns.Add(new LookUpColumnInfo("ADOTFactorName", "Tên")); repositoryItemLookUpEdit.Columns.Add(new LookUpColumnInfo("ADOTFactorType", "Loại")); repositoryItemLookUpEdit.Columns.Add(new LookUpColumnInfo("ADOTFactorValue", "Hệ sô")); repositoryItemLookUpEdit.QueryPopUp += new System.ComponentModel.CancelEventHandler(repositoryItemLookUpEdit_QueryPopUp2); column.ColumnEdit = repositoryItemLookUpEdit; } column = gridView.Columns["HROTFactorToTime"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } gridView.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(GridView_FocusedRowChanged); gridView.KeyUp += new KeyEventHandler(GridView_KeyUp); gridView.CustomColumnDisplayText += new DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventHandler(gridView_CustomColumnDisplayText); return(gridView); }
/// <summary> /// 初始化列, /// </summary> public void InitColumns() { //需要隐藏列时在这写代码 DevExpress.XtraEditors.Repository.RepositoryItemDateEdit dEdit = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); dEdit.EditFormat.FormatType = DevExpress.Utils.FormatType.Custom; dEdit.Mask.EditMask = "yyyy-MM-dd HH:mm"; dEdit.Mask.UseMaskAsDisplayFormat = true; gridView1.Columns["sj"].ColumnEdit = dEdit; hideColumn("c1"); hideColumn("c2"); hideColumn("c3"); hideColumn("wgdn"); }
protected override DevExpress.XtraGrid.Views.Grid.GridView InitializeGridView() { DevExpress.XtraGrid.Views.Grid.GridView gridView = base.InitializeGridView(); repositoryItemDateEdit = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); gridView.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom; foreach (GridColumn columnedit in gridView.Columns) { columnedit.OptionsColumn.AllowEdit = true; } // repositoryItemDateEdit repositoryItemDateEdit.AutoHeight = false; repositoryItemDateEdit.DisplayFormat.FormatString = "HH:mm:ss"; repositoryItemDateEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; repositoryItemDateEdit.EditFormat.FormatString = "HH:mm:ss"; repositoryItemDateEdit.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime; repositoryItemDateEdit.Mask.EditMask = "HH:mm:ss"; repositoryItemDateEdit.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; repositoryItemDateEdit.Name = "repositoryItemDateEdit1"; GridColumn column = gridView.Columns["ADWorkingShiftName"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["ADWorkingShiftDesc"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["ADWorkingShiftFromTime"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["ADWorkingShiftToTime"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["ADWorkingShiftBreakTimeBetweenFrom"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["ADWorkingShiftBreakTimeBetweenTo"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["ADWorkingShiftTimeKeepInFrom"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["ADWorkingShiftTimeKeepInTo"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["ADWorkingShiftTimeKeepOutFrom"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["ADWorkingShiftTimeKeepOutTo"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["ADWorkingShiftNight"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["ADWorkingShiftWorkingTime"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["FK_ADWorkingShiftGroupID"]; if (column != null) { column.OptionsColumn.AllowEdit = true; RepositoryItemLookUpEdit repositoryItemLookUpEdit = new RepositoryItemLookUpEdit(); repositoryItemLookUpEdit.DisplayMember = "ADWorkingShiftGroupName"; repositoryItemLookUpEdit.ValueMember = "ADWorkingShiftGroupID"; repositoryItemLookUpEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; repositoryItemLookUpEdit.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoFilter; repositoryItemLookUpEdit.NullText = string.Empty; repositoryItemLookUpEdit.Columns.Add(new LookUpColumnInfo("ADWorkingShiftGroupName", "Nhóm ca")); repositoryItemLookUpEdit.QueryPopUp += new CancelEventHandler(repositoryItemLookUpEdit2_QueryPopUp); column.ColumnEdit = repositoryItemLookUpEdit; } //column = gridView.Columns["ADWorkingShiftAllowance"]; //if (column != null) //{ // column.OptionsColumn.AllowEdit = true; //} gridView.InvalidRowException += new InvalidRowExceptionEventHandler(GridView_InvalidRowException); gridView.CustomColumnDisplayText += new CustomColumnDisplayTextEventHandler(gridView_CustomColumnDisplayText); gridView.KeyUp += new KeyEventHandler(GridView_KeyUp); return(gridView); }
/// <summary> /// Sets the column. /// </summary> /// <param name="strheader">The strheader.</param> /// <param name="strFieldsName">Name of the STR fields.</param> /// <param name="ct">The ct.</param> /// <param name="nWidth">Width of the n.</param> /// <param name="mAlign">The m align.</param> /// <param name="bVisible">if set to <c>true</c> [b visible].</param> /// <param name="IsAllowEdit">if set to <c>true</c> [is allow edit].</param> /// <param name="IsAllowSort">The is allow sort.</param> /// <returns></returns> private DevExpress.XtraGrid.Columns.GridColumn SetColumn(string strheader, string strFieldsName, _ColumnType ct, int nWidth, _ColumnAlign mAlign, bool bVisible, bool IsAllowEdit, DefaultBoolean IsAllowSort, AutoFilterCondition autoFilterCondition, bool IsAllowMove) { DevExpress.XtraGrid.Columns.GridColumn gc = new GridColumn(); gc.Caption = strheader; gc.FieldName = strFieldsName; gc.Name = strFieldsName; gc.Width = nWidth; //// 헤더 텍스트 옵션을 사용한다. gc.AppearanceHeader.Options.UseTextOptions = true; gc.OptionsColumn.AllowMerge = DefaultBoolean.False; // 셀 텍스트 옵션을 사용한다. gc.AppearanceCell.Options.UseTextOptions = true; gc.AppearanceCell.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Default; gc.AppearanceCell.TextOptions.HAlignment = (DevExpress.Utils.HorzAlignment)mAlign; gc.AppearanceHeader.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Default; gc.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gc.Visible = bVisible; gc.OptionsColumn.AllowEdit = IsAllowEdit; gc.OptionsColumn.AllowMove = IsAllowMove; gc.OptionsColumn.ReadOnly = !IsAllowEdit; gc.OptionsColumn.AllowSort = IsAllowSort; gc.VisibleIndex = bVisible ? iVisibleIndex++ : -1; gc.OptionsFilter.AllowAutoFilter = true; //gc.OptionsFilter.AllowFilter = false; gc.OptionsFilter.AutoFilterCondition = autoFilterCondition; gc.OptionsFilter.ImmediateUpdateAutoFilter = true; gc.AppearanceHeader.Font = new System.Drawing.Font("굴림체", 9F); gc.AppearanceHeader.Options.UseFont = true; if (ct > 0) { switch (ct) { case _ColumnType.CheckBox: if (this._GridControl != null) { mCheckBox = new RepositoryItemCheckEdit(); this._GridControl.RepositoryItems.Add(SetCheckBoxStyle(mCheckBox, CheckBoxStyle.StyleYN)); gc.ColumnEdit = mCheckBox; //gc.OptionsColumn.AllowEdit= true; //gc.OptionsColumn.ReadOnly = false; } break; case _ColumnType.CheckBoxBit: if (this._GridControl != null) { mCheckBox = new RepositoryItemCheckEdit(); this._GridControl.RepositoryItems.Add(SetCheckBoxStyle(mCheckBox, CheckBoxStyle.StyleBit)); gc.ColumnEdit = mCheckBox; //gc.OptionsColumn.AllowEdit= true; //gc.OptionsColumn.ReadOnly = false; } break; case _ColumnType.Picture: if (this._GridControl != null) { mPicture = new RepositoryItemPictureEdit(); mPicture.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Stretch; this._GridControl.RepositoryItems.Add(mPicture); gc.ColumnEdit = mPicture; //gc.OptionsColumn.AllowEdit= true; //gc.OptionsColumn.ReadOnly = false; } break; case _ColumnType.Numbers: gc.DisplayFormat.FormatType = FormatType.Numeric; gc.DisplayFormat.FormatString = "n0"; break; case _ColumnType.Dates: gc.DisplayFormat.FormatType = FormatType.DateTime; gc.DisplayFormat.FormatString = "yyyy-MM-dd"; break; case _ColumnType.DateTime: gc.DisplayFormat.FormatType = FormatType.DateTime; gc.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss"; break; case _ColumnType.ComboBox: mComboBox = new RepositoryItemComboBox(); mComboBox.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; this._GridControl.RepositoryItems.Add(mComboBox); gc.ColumnEdit = mComboBox; //gc.OptionsColumn.ReadOnly = false; //gc.OptionsColumn.AllowEdit= true; break; case _ColumnType.doubles1: gc.DisplayFormat.FormatType = FormatType.Numeric; gc.DisplayFormat.FormatString = "n1"; break; case _ColumnType.doubles2: gc.DisplayFormat.FormatType = FormatType.Numeric; gc.DisplayFormat.FormatString = "n2"; break; case _ColumnType.TextEdit: mTextEdit = new RepositoryItemTextEdit(); this._GridControl.RepositoryItems.Add(mTextEdit); gc.ColumnEdit = mTextEdit; //gc.OptionsColumn.ReadOnly = false; //gc.OptionsColumn.AllowEdit= true; break; case _ColumnType.Amount: gc.DisplayFormat.FormatType = FormatType.Numeric; gc.DisplayFormat.FormatString = "###,###"; break; case _ColumnType.LookUp: mLookUp = new RepositoryItemLookUpEdit(); mLookUp.Name = "LOOKUP_" + gc.FieldName; //mLookUp.Properties.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoComplete; //mLookUp.Properties.AutoSearchColumnIndex = 0; mLookUp.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoComplete; mLookUp.AutoSearchColumnIndex = 0; this._GridControl.RepositoryItems.Add(mLookUp); gc.ColumnEdit = mLookUp; //gc.OptionsColumn.ReadOnly = false; //gc.OptionsColumn.AllowEdit= true; break; case _ColumnType.Radio: if (this._GridControl != null) { mRadio = new RepositoryItemRadioGroup(); this._GridControl.RepositoryItems.Add(mRadio); gc.ColumnEdit = mRadio; //gc.OptionsColumn.ReadOnly = false; //gc.OptionsColumn.AllowEdit= true; } break; case _ColumnType.RichEdit: if (this._GridControl != null) { mRichEdit = new RepositoryItemRichTextEdit(); this._GridControl.RepositoryItems.Add(mRichEdit); gc.ColumnEdit = mRichEdit; //gc.OptionsColumn.ReadOnly = false; //gc.OptionsColumn.AllowEdit= true; } break; case _ColumnType.Button: if (this._GridControl != null) { mBtn = new RepositoryItemButtonEdit(); mBtn.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor; mBtn.Buttons[0].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph; //mBtn.Properties.Buttons[0].Caption = "확인"; mBtn.Properties.Buttons[0].Appearance.ForeColor = Color.Black; this._GridControl.RepositoryItems.Add(mBtn); gc.ColumnEdit = mBtn; //gc.OptionsColumn.ReadOnly = false; //gc.OptionsColumn.AllowEdit= true; } break; case _ColumnType.DataTimepicker: if (this._GridControl != null) { mDateEdit = new RepositoryItemDateEdit(); mDateEdit.EditFormat.FormatType = FormatType.DateTime; mDateEdit.DisplayFormat.FormatString = "yyyy-MM-dd"; mDateEdit.Appearance.ForeColor = Color.Black; this._GridControl.RepositoryItems.Add(mDateEdit); gc.ColumnEdit = mDateEdit; //gc.OptionsColumn.ReadOnly = false; //gc.OptionsColumn.AllowEdit= true; } break; case _ColumnType.Progressbar: if (this._GridControl != null) { mProgressBar = new RepositoryItemProgressBar(); mProgressBar.ShowTitle = true; mProgressBar.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid; mProgressBar.PercentView = true; mProgressBar.ProgressKind = DevExpress.XtraEditors.Controls.ProgressKind.Horizontal; mProgressBar.NullText = "0"; mProgressBar.Step = 1; mProgressBar.EditFormat.FormatType = FormatType.Numeric; mProgressBar.EditFormat.FormatString = "n2"; this._GridControl.RepositoryItems.Add(mProgressBar); gc.ColumnEdit = mProgressBar; //gc.OptionsColumn.ReadOnly = false; //gc.OptionsColumn.AllowEdit= true; } break; default: break; } } return(gc); }
/// <summary> /// 根据字段的类型名称获取一个XtrGrid 的编辑控件。 /// </summary> /// <param name="fullTypeName"></param> /// <param name="isCard"> 如果是卡片编辑的话图片的显示使用PictureEdit的方式。</param> /// <returns></returns> public DevExpress.XtraEditors.Repository.RepositoryItem createEditItemByCol(string fullTypeName, bool isCard, MB.WinBase.Common.ColumnPropertyInfo propertyInfo) { DevExpress.XtraEditors.Repository.RepositoryItem item = null; switch (fullTypeName) { case "System.Int16": DevExpress.XtraEditors.Repository.RepositoryItemSpinEdit int16Item = new DevExpress.XtraEditors.Repository.RepositoryItemSpinEdit(); int16Item.IsFloatValue = false; int16Item.EditMask = "N00"; int16Item.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric; item = int16Item; if (propertyInfo != null) { if (propertyInfo.MinValue > Int32.MinValue) { int16Item.MinValue = System.Convert.ToInt16(propertyInfo.MinValue); } if (propertyInfo.MaxValue < Int32.MaxValue) { int16Item.MaxValue = System.Convert.ToInt16(propertyInfo.MaxValue); } } break; case "System.Int32": item = CreateEditItemInt32(propertyInfo); break; case "System.Decimal": DevExpress.XtraEditors.Repository.RepositoryItemCalcEdit deciItem = new XtraRepositoryItemCalcEditEx(); deciItem.MaxLength = 12; //初不设置的一个数,需要修改; item = deciItem; break; case "System.DateTime": DevExpress.XtraEditors.Repository.RepositoryItemDateEdit dateItem = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); dateItem.NullDate = DateTime.MinValue; dateItem.NullText = string.Empty; dateItem.AutoHeight = false; item = dateItem; break; case "System.Boolean": //目前Boolean 先用CheckedBox 来表达,如果需要再修改为Group Radio DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit boolItem = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit(); item = boolItem; break; case "System.Byte[]": if (!isCard) { DevExpress.XtraEditors.Repository.RepositoryItemImageEdit imageItem = new DevExpress.XtraEditors.Repository.RepositoryItemImageEdit(); //imageItem.NullText = ""; item = imageItem; } else { DevExpress.XtraEditors.Repository.RepositoryItemPictureEdit picItem = new DevExpress.XtraEditors.Repository.RepositoryItemPictureEdit(); item = picItem; } break; default: DevExpress.XtraEditors.Repository.RepositoryItemTextEdit txtItem = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit(); item = txtItem; break; } return(item);//new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit(); }
private static void InitializeColumnA(DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView view, string ColumnName, _ColumnType type, _ColumnAlign mAlign, bool IsVisible, bool IsAllowEdit, bool IsAllowMove) { try { view.Columns[ColumnName].AppearanceHeader.Options.UseTextOptions = true; // 셀 텍스트 옵션을 사용한다. view.Columns[ColumnName].AppearanceCell.Options.UseTextOptions = true; view.Columns[ColumnName].AppearanceCell.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Default; view.Columns[ColumnName].AppearanceCell.TextOptions.HAlignment = (DevExpress.Utils.HorzAlignment)mAlign; view.Columns[ColumnName].AppearanceHeader.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Default; view.Columns[ColumnName].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; view.Columns[ColumnName].Visible = IsVisible; if (IsVisible) { view.Columns[ColumnName].VisibleIndex = view.Columns.Count; } else { view.Columns[ColumnName].VisibleIndex = -1; } view.Columns[ColumnName].OptionsColumn.AllowMove = IsAllowMove; view.Columns[ColumnName].OptionsColumn.AllowSize = true; view.Columns[ColumnName].OptionsColumn.AllowEdit = IsAllowEdit; view.Columns[ColumnName].OptionsColumn.ReadOnly = !IsAllowEdit; switch (type) { case _ColumnType.CheckBox: mCheckBox = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit(); mCheckBox.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Style4; mCheckBox.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked; mCheckBox.ValueChecked = "Y"; mCheckBox.ValueUnchecked = "N"; view.GridControl.RepositoryItems.Add(mCheckBox); view.Columns[ColumnName].ColumnEdit = mCheckBox; break; case _ColumnType.CheckBoxBit: mCheckBox = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit(); mCheckBox.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Style4; mCheckBox.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked; mCheckBox.ValueChecked = "1"; mCheckBox.ValueUnchecked = "0"; view.GridControl.RepositoryItems.Add(mCheckBox); view.Columns[ColumnName].ColumnEdit = mCheckBox; break; case _ColumnType.Picture: mPicture = new RepositoryItemPictureEdit(); mPicture.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Stretch; view.GridControl.RepositoryItems.Add(mPicture); view.Columns[ColumnName].ColumnEdit = mPicture; break; case _ColumnType.Numbers: view.Columns[ColumnName].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; view.Columns[ColumnName].DisplayFormat.FormatString = "n0"; break; case _ColumnType.Dates: view.Columns[ColumnName].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; view.Columns[ColumnName].DisplayFormat.FormatString = "yyyy-MM-dd"; break; case _ColumnType.DateTime: view.Columns[ColumnName].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; view.Columns[ColumnName].DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss"; break; case _ColumnType.ComboBox: mComboBox = new RepositoryItemComboBox(); mComboBox.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; view.GridControl.RepositoryItems.Add(mComboBox); view.Columns[ColumnName].ColumnEdit = mComboBox; break; case _ColumnType.doubles1: view.Columns[ColumnName].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; view.Columns[ColumnName].DisplayFormat.FormatString = "n1"; break; case _ColumnType.doubles2: view.Columns[ColumnName].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; view.Columns[ColumnName].DisplayFormat.FormatString = "n2"; break; case _ColumnType.TextEdit: mTextEdit = new RepositoryItemTextEdit(); view.GridControl.RepositoryItems.Add(mTextEdit); view.Columns[ColumnName].ColumnEdit = mTextEdit; break; case _ColumnType.Amount: view.Columns[ColumnName].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; view.Columns[ColumnName].DisplayFormat.FormatString = "###,###"; break; case _ColumnType.Radio: mRadio = new RepositoryItemRadioGroup(); view.GridControl.RepositoryItems.Add(mRadio); view.Columns[ColumnName].ColumnEdit = mRadio; break; case _ColumnType.LookUp: mLookUp = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit(); mLookUp.Name = "LOOKUP_" + view.Columns[ColumnName].Name; //mLookUp.Properties.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoComplete; //mLookUp.Properties.AutoSearchColumnIndex = 0; view.GridControl.RepositoryItems.Add(mLookUp); view.Columns[ColumnName].ColumnEdit = mLookUp; break; case _ColumnType.RichEdit: mRichEdit = new RepositoryItemRichTextEdit(); view.GridControl.RepositoryItems.Add(mRichEdit); view.Columns[ColumnName].ColumnEdit = mRichEdit; break; case _ColumnType.Button: mBtn = new RepositoryItemButtonEdit(); mBtn.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor; mBtn.Buttons[0].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph; //mBtn.Properties.Buttons[0].Caption = "확인"; mBtn.Properties.Buttons[0].Appearance.ForeColor = System.Drawing.Color.Black; view.GridControl.RepositoryItems.Add(mBtn); view.Columns[ColumnName].ColumnEdit = mBtn; break; case _ColumnType.DataTimepicker: if (view.GridControl != null) { mDateEdit = new RepositoryItemDateEdit(); mDateEdit.EditFormat.FormatType = FormatType.DateTime; mDateEdit.DisplayFormat.FormatString = "yyyy-MM-dd"; mDateEdit.Appearance.ForeColor = Color.Black; view.GridControl.RepositoryItems.Add(mDateEdit); view.Columns[ColumnName].ColumnEdit = mDateEdit; //gc.OptionsColumn.ReadOnly = false; //gc.OptionsColumn.AllowEdit= true; } break; default: break; } } catch (Exception ex) { throw ex; } }
protected override DevExpress.XtraGrid.Views.Grid.GridView InitializeGridView() { GridView gridView = base.InitializeGridView(); gridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom; repositoryItemDateEdit = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); // repositoryItemDateEdit repositoryItemDateEdit.AutoHeight = false; repositoryItemDateEdit.DisplayFormat.FormatString = "HH:mm:ss"; repositoryItemDateEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; repositoryItemDateEdit.EditFormat.FormatString = "HH:mm:ss"; repositoryItemDateEdit.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime; repositoryItemDateEdit.Mask.EditMask = "HH:mm:ss"; repositoryItemDateEdit.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; repositoryItemDateEdit.Name = "repositoryItemDateEdit1"; GridColumn column = gridView.Columns["HRWorkingShiftName"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["FK_ADWorkingShiftID"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["HRWorkingShiftDesc"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["HRWorkingShiftFromTime"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["HRWorkingShiftDayOffWeek"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["HRWorkingShiftToTime"]; if (column != null) { column.OptionsColumn.AllowEdit = true; column.ColumnEdit = repositoryItemDateEdit; } column = gridView.Columns["HRWorkingShiftNight"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["HRWorkingShiftTimeBreak"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["HRWorkingShiftWorkingTime"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["HRWorkingShiftIsDefault"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = gridView.Columns["HRWorkingShiftAllowance"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } gridView.InvalidRowException += new InvalidRowExceptionEventHandler(GridView_InvalidRowException); gridView.KeyUp += new KeyEventHandler(GridView_KeyUp); return(gridView); }
protected override void AddColumnsToGridView(string strTableName, GridView gridView) { base.AddColumnsToGridView(strTableName, gridView); GridColumn column = new GridColumn(); column.Caption = "Tên nhân viên"; column.FieldName = "EmployeeName"; column.OptionsColumn.AllowEdit = false; column.Group(); gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Thứ"; column.FieldName = "ThName"; column.OptionsColumn.AllowEdit = false; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Vào/Ra"; column.FieldName = "HRTimeKeeperCompleteInOutMode"; column.OptionsColumn.AllowEdit = true; gridView.Columns.Add(column); column = new GridColumn(); column = gridView.Columns["HRTimeKeeperCompleteTimeCheck"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = new GridColumn(); column = gridView.Columns["HRTimeKeeperCompletesEmployeeCardNo"]; if (column != null) { column.Group(); } column = new GridColumn(); column = gridView.Columns["HRTimeKeeperCompleteDate"]; if (column != null) { column.Group(); } column = gridView.Columns["HRTimeKeeperCompleteDateCheck"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = new GridColumn(); column = gridView.Columns["HRTimeKeeperCompleteComment"]; if (column != null) { column.OptionsColumn.AllowEdit = true; } column = new GridColumn(); column = gridView.Columns["FK_HRDepartmentID"]; if (column != null) { column.OptionsColumn.AllowEdit = false; } column = new GridColumn(); column = gridView.Columns["FK_HRLevelID"]; if (column != null) { column.OptionsColumn.AllowEdit = false; } column = new GridColumn(); column.Caption = "Xóa dữ liệu"; column.FieldName = "DiscardItem"; RepositoryItemHyperLinkEdit rep = new RepositoryItemHyperLinkEdit(); rep.NullText = "Hủy"; rep.LinkColor = Color.Blue; rep.Click += new EventHandler(rep_Click); column.ColumnEdit = rep; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Trùng giờ"; column.FieldName = "SameDateTime"; column.OptionsColumn.AllowEdit = false; gridView.Columns.Add(column); repositoryItemDateEdit = new DevExpress.XtraEditors.Repository.RepositoryItemDateEdit(); // repositoryItemDateEdit repositoryItemDateEdit.AutoHeight = false; repositoryItemDateEdit.DisplayFormat.FormatString = "HH:mm:ss"; repositoryItemDateEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; repositoryItemDateEdit.Mask.EditMask = "HH:mm:ss"; repositoryItemDateEdit.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; repositoryItemDateEdit.Name = "repositoryItemDateEdit1"; column = new GridColumn(); column.Caption = "Bộ phận"; column.FieldName = "HRDepartmentRoomName"; column.OptionsColumn.AllowEdit = false; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Tổ"; column.FieldName = "HRDepartmentRoomGroupItemName"; column.OptionsColumn.AllowEdit = false; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Nhóm chấm công"; column.FieldName = "HREmployeePayrollFormulaName"; column.OptionsColumn.AllowEdit = false; gridView.Columns.Add(column); column = new GridColumn(); column.Caption = "Mã màu"; column.FieldName = "RowColor"; column.OptionsColumn.AllowEdit = false; gridView.Columns.Add(column); }