public virtual void InitializeControl() { this.LookupTables = ((IBaseModuleERP)this.Screen.Module).GetLookupTableCollection(); this.LookupTableObjects = ((IBaseModuleERP)this.Screen.Module).GetLookupTableObjects(); GridView gridView = this.InitializeGridView(); this.MainView = (BaseView)gridView; this.InitGridControlDataSource(); this.UseEmbeddedNavigator = true; this.EmbeddedNavigator.Name = "navigator_" + this.Name; NavigatorCustomButton navigatorCustomButton1 = new NavigatorCustomButton(8, "Cấu hình hiển thị"); navigatorCustomButton1.Tag = (object)"CustomizeColumn"; NavigatorCustomButton navigatorCustomButton2 = new NavigatorCustomButton(9, "Lưu cấu hình"); navigatorCustomButton2.Tag = (object)"SaveColumnCustomization"; this.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[2] { navigatorCustomButton1, navigatorCustomButton2 }); this.EmbeddedNavigator.Buttons.Edit.Visible = false; this.EmbeddedNavigator.Buttons.Remove.Visible = false; this.EmbeddedNavigator.Buttons.Append.Visible = false; this.EmbeddedNavigator.ButtonClick += new NavigatorButtonClickEventHandler(this.NavigatorButton_Click); gridView.ValidateRow += new ValidateRowEventHandler(this.GridView_ValidateRow); }
/// <summary> /// 设置表格控件的布局. 比如按钮设置. /// </summary> public static void SetGridControlLayout(GridControl grid, bool allowEdit) { ControlNavigatorButtons btns = grid.EmbeddedNavigator.Buttons; grid.BeginInit(); grid.EmbeddedNavigator.ButtonStyle = BorderStyles.Office2003; grid.UseEmbeddedNavigator = true; btns.Append.Visible = false; btns.CancelEdit.Visible = false; btns.Edit.Visible = false; btns.Remove.Visible = false; btns.EndEdit.Visible = false; btns.NextPage.Visible = false; btns.PrevPage.Visible = false; ((GridView)grid.Views[0]).OptionsBehavior.Editable = allowEdit; //允许编辑状态 if (allowEdit) //增加两个自定义按钮(ADD,INSERT,DELETE) { ImageList img = new ImageList(); img.Images.Add(Globals.LoadImage("16_Add.ico")); img.Images.Add(Globals.LoadImage("16_Insert.ico")); img.Images.Add(Globals.LoadImage("16_Delete.ico")); grid.EmbeddedNavigator.Buttons.ImageList = img; btns.CustomButtons.Clear(); NavigatorCustomButton btnDtlAdd = new NavigatorCustomButton((int)DetailButtons.Add, "新增记录"); NavigatorCustomButton btnDtlInsert = new NavigatorCustomButton((int)DetailButtons.Insert, "插入记录"); NavigatorCustomButton btnDtlDelete = new NavigatorCustomButton((int)DetailButtons.Delete, "删除记录"); btns.CustomButtons.AddRange(new NavigatorCustomButton[] { btnDtlAdd, btnDtlInsert, btnDtlDelete }); } grid.EndInit(); }
public void InitializeControl() { this.LookupTables = ((IBaseModuleERP)this.Screen.Module).GetLookupTableCollection(); this.LookupTableObjects = ((IBaseModuleERP)this.Screen.Module).GetLookupTableObjects(); GridView dgvSearchResults = InitializeSearchResultsGridView(); this.ViewCollection.Add(dgvSearchResults); this.MainView = dgvSearchResults; dgvSearchResults.GridControl = this; this.MouseDoubleClick += new MouseEventHandler(GridControlSearchResults_MouseDoubleClick); //this.KeyUp += new KeyEventHandler(((IBaseModuleERP)Screen.Module).Control_KeyUp); //Using embedded Navigator this.UseEmbeddedNavigator = true; this.EmbeddedNavigator.Name = "navigator_" + this.Name; NavigatorCustomButton customizeColumnButton = new NavigatorCustomButton(8, "Cấu hình hiển thị"); customizeColumnButton.Tag = "CustomizeColumn"; NavigatorCustomButton saveColumnCustomizationButton = new NavigatorCustomButton(9, "Lưu cấu hình"); saveColumnCustomizationButton.Tag = "SaveColumnCustomization"; this.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new DevExpress.XtraEditors.NavigatorCustomButton[] { customizeColumnButton, saveColumnCustomizationButton }); this.EmbeddedNavigator.Buttons.Remove.Visible = false; this.EmbeddedNavigator.Buttons.EndEdit.Visible = false; this.EmbeddedNavigator.Buttons.CancelEdit.Visible = false; this.EmbeddedNavigator.Buttons.Edit.Visible = false; this.EmbeddedNavigator.Buttons.Append.Visible = false; //Add events to navigator buttons this.EmbeddedNavigator.ButtonClick += new DevExpress.XtraEditors.NavigatorButtonClickEventHandler(NavigatorButton_Click); }
private void ShowEvent(string eventString, NavigatorButtonBase button) { //string type = button.ButtonType.ToString(); NavigatorCustomButton btn = (NavigatorCustomButton)button; string type = btn.Tag.ToString(); if (type == "首页") { PageIndex = 1; } if (type == "下一页") { PageIndex++; } if (type == "末页") { PageIndex = PageCount; } if (type == "上一页") { PageIndex--; } BindPageGridList(); }
/// <summary> /// 在表格导航按钮内增加一个自定义按钮 /// </summary> /// <param name="grid">表格控件</param> /// <param name="buttonID">按钮编号</param> /// <param name="buttonImage">按钮图片</param> /// <param name="buttonHint">按钮提示消息</param> public static void AddCustomButton(GridControl grid, int buttonID, Image buttonImage, string buttonHint) { grid.BeginInit(); ImageList list = grid.EmbeddedNavigator.Buttons.ImageList as ImageList; list.Images.Add(buttonImage); NavigatorCustomButton btn = new NavigatorCustomButton(buttonID, buttonHint); grid.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btn }); grid.EndInit(); }
public FrmSetupStatus() { InitializeComponent(); repository = new StatusRepository(); BtnAdd = controlNavigator1.Buttons.CustomButtons[0]; BtnEdit = controlNavigator1.Buttons.CustomButtons[1]; BtnSave = controlNavigator1.Buttons.CustomButtons[2]; BtnCancel = controlNavigator1.Buttons.CustomButtons[3]; BtnSwitch = controlNavigator1.Buttons.CustomButtons[4]; BtnRefresh = controlNavigator1.Buttons.CustomButtons[5]; }
public GenericGridLookUpEdit() : base() { Properties.View.GridControl.UseEmbeddedNavigator = true; Properties.View.GridControl.EmbeddedNavigator.Buttons.Append.Visible = false; Properties.View.GridControl.EmbeddedNavigator.Buttons.CancelEdit.Visible = false; Properties.View.GridControl.EmbeddedNavigator.Buttons.Edit.Visible = false; Properties.View.GridControl.EmbeddedNavigator.Buttons.EndEdit.Visible = false; Properties.View.GridControl.EmbeddedNavigator.Buttons.Remove.Visible = false; Properties.View.GridControl.EmbeddedNavigator.Buttons.ImageList = _imageListClearButton; Properties.View.GridControl.EmbeddedNavigator.Buttons.CustomButtons.Clear(); _clearButton = Properties.View.GridControl.EmbeddedNavigator.Buttons.CustomButtons.Add(); _clearButton.ImageIndex = 0; _clearButton.Hint = ControlsRes.GenericGridLookUpEdit_Clear; Properties.View.GridControl.EmbeddedNavigator.ButtonClick += new NavigatorButtonClickEventHandler(Navigator_ButtonClick); }
public void CanAddAndRemove_From_NavigatorCustomButtonUIAdapter() { var gridControl = new GridControl(); NavigatorCustomButtons buttons = gridControl.EmbeddedNavigator.Buttons.CustomButtons; IUIElementAdapter adapter = new NavigatorCustomButtonUIAdapterFactory().GetAdapter(buttons); Assert.IsType(typeof(NavigatorCustomButtonUIAdapter), adapter); //add var button = new NavigatorCustomButton(0); var addedButton = adapter.Add(button); Assert.Equal(button, addedButton as NavigatorCustomButton); Assert.Equal(1, gridControl.EmbeddedNavigator.Buttons.CustomButtons.Count); //remove adapter.Remove(button); Assert.Equal(0, gridControl.EmbeddedNavigator.Buttons.CustomButtons.Count); }
public FrmAddItemQuantity() { InitializeComponent(); itemRepository = new ItemRepository(); BtnAdd = controlNavigator1.Buttons.CustomButtons[0]; BtnSave = controlNavigator1.Buttons.CustomButtons[2]; BtnCancel = controlNavigator1.Buttons.CustomButtons[3]; BtnSwitch = controlNavigator1.Buttons.CustomButtons[4]; BtnRefresh = controlNavigator1.Buttons.CustomButtons[5]; controlNavigator1.Buttons.ImageList = sharedImageCollection1; controlNavigator1.Buttons.CustomButtons[0].ImageIndex = 0; controlNavigator1.Buttons.CustomButtons[2].ImageIndex = 2; controlNavigator1.Buttons.CustomButtons[3].ImageIndex = 3; controlNavigator1.Buttons.CustomButtons[4].ImageIndex = 4; controlNavigator1.Buttons.CustomButtons[5].ImageIndex = 5; }
private void dataNavigator1_ButtonClick(object sender, NavigatorButtonClickEventArgs e) { NavigatorButtonType btnType = (NavigatorButtonType)e.Button.ButtonType; if (e.Button is NavigatorCustomButton) { NavigatorCustomButton btn = (NavigatorCustomButton)e.Button; if (btn.Tag.ToString() == "下一页" && now_Page < total_Page) { now_Page++; dataNavigator_FundAccount.TextStringFormat = string.Format("第 {0}页,共 {1}页", now_Page, total_Page); domain.Fund_Accounts bs = new domain.Fund_Accounts(); gridControl2.DataSource = fc.showData <domain.Fund_Accounts>(bs, now_Page.ToString()); } else if (btn.Tag.ToString() == "上一页" && now_Page > 1) { now_Page--; dataNavigator_FundAccount.TextStringFormat = string.Format("第 {0}页,共 {1}页", now_Page, total_Page); domain.Fund_Accounts bs = new domain.Fund_Accounts(); gridControl2.DataSource = fc.showData <domain.Fund_Accounts>(bs, now_Page.ToString()); } else if (btn.Tag.ToString() == "首页") { now_Page = 1; dataNavigator_FundAccount.TextStringFormat = string.Format("第 {0}页,共 {1}页", now_Page, total_Page); domain.Fund_Accounts bs = new domain.Fund_Accounts(); gridControl2.DataSource = fc.showData <domain.Fund_Accounts>(bs, now_Page.ToString()); } else if (btn.Tag.ToString() == "尾页") { now_Page = total_Page; dataNavigator_FundAccount.TextStringFormat = string.Format("第 {0}页,共 {1}页", now_Page, total_Page); domain.Fund_Accounts bs = new domain.Fund_Accounts(); gridControl2.DataSource = fc.showData <domain.Fund_Accounts>(bs, now_Page.ToString()); } } }
public CGridControl(NavigatorCustomButton btnRowHeight) { _btnRowHeight = btnRowHeight; ShowCustomNavigationButtons = false; }
/// <summary> /// 加载和保存界面grid风格 /// 1、包含菜单项:列配置、行号、行高,无高级查询选项 /// 2、不包含分页字段排序查询 /// </summary> /// <param name="barManager">barManager</param> /// <param name="moduleName">模块名称</param> public void LoadGridLayout(BarManager barManager, string moduleName) { try { _moduleName = moduleName; _layoutXmlName = MainView.Name + ".xml"; // layoutXMLName; _strPath = AppDomain.CurrentDomain.BaseDirectory + _stylePath + "\\" + Program.CurrentEmployee.EmployeeCode; _rowNumberName = Program.CurrentEmployee.EmployeeCode + "_" + moduleName + "_" + _layoutXmlName; _immediatelyDownloadName = Program.CurrentEmployee.EmployeeCode + "_" + moduleName + "_" + _layoutXmlName; //加载界面grid风格 if (LayOutIsAlive(@"\" + moduleName + "\\" + _layoutXmlName)) //如果有grid样式,则加载 { MainView.RestoreLayoutFromXml(_strPath + @"\" + moduleName + "\\" + _layoutXmlName, OptionsLayoutBase.FullLayout); //取出所有gridview样式信息 } else if (!LayOutIsAlive(@"\" + moduleName + "\\" + "Default_" + _layoutXmlName)) //保存默认gridview样式,用于还原 { try { if (!Directory.Exists(_strPath + @"\" + _moduleName)) { Directory.CreateDirectory(_strPath + @"\" + _moduleName); } MainView.SaveLayoutToXml(_strPath + @"\" + _moduleName + "\\Default_" + _layoutXmlName, OptionsLayoutBase.FullLayout); //保存所有信息 } catch { // ignored } } //注册离开界面保存grid风格事件,行号状态 ControlRemoved += gc_ControlRemoved; LoadGridHeaderMenu(barManager); if (ShowCustomNavigationButtons || ShowCustomRowHeightButton) { var imageList1 = new ImageList { ImageSize = new Size(36, 16) }; imageList1.Images.Add(Resources.grid_insert); imageList1.Images.Add(Resources.grid_add); imageList1.Images.Add(Resources.grid_delete); imageList1.Images.Add(Resources.grid_cancel); imageList1.Images.Add(Resources.grid_rowHeight); UseEmbeddedNavigator = true; EmbeddedNavigator.Buttons.ImageList = imageList1; //禁用自带按钮 EmbeddedNavigator.Buttons.Append.Visible = false; //新增 EmbeddedNavigator.Buttons.CancelEdit.Visible = false; //取消编辑 EmbeddedNavigator.Buttons.EndEdit.Visible = false; //结束编辑 EmbeddedNavigator.Buttons.Prev.Visible = false; //上一条 EmbeddedNavigator.Buttons.PrevPage.Visible = false; //上一页 EmbeddedNavigator.Buttons.Next.Visible = false; //下一条 EmbeddedNavigator.Buttons.NextPage.Visible = false; //下一页 EmbeddedNavigator.Buttons.First.Visible = false; //第一条 EmbeddedNavigator.Buttons.Last.Visible = false; //最后一条 EmbeddedNavigator.Buttons.Edit.Visible = false; //编辑 EmbeddedNavigator.Buttons.Remove.Visible = false; //删除 EmbeddedNavigator.TextLocation = NavigatorButtonsTextLocation.End; EmbeddedNavigator.Text = string.Empty; EmbeddedNavigator.TextStringFormat = string.Empty; EmbeddedNavigator.ButtonClick += gridControl_EmbeddedNavigator_ButtonClick; } if (ShowCustomNavigationButtons) { _btnInsert = new NavigatorCustomButton(); _btnInsert = EmbeddedNavigator.Buttons.CustomButtons.Add(); _btnInsert.Tag = "insert"; //btn_insert.Hint = "插入"; _btnInsert.ImageIndex = 0; _btnAdd = new NavigatorCustomButton(); _btnAdd = EmbeddedNavigator.Buttons.CustomButtons.Add(); _btnAdd.Tag = "add"; // btn_add.Hint = "追加"; _btnAdd.ImageIndex = 1; _btnDelete = new NavigatorCustomButton(); _btnDelete = EmbeddedNavigator.Buttons.CustomButtons.Add(); _btnDelete.Tag = "delete"; //btn_delete.Hint = "删除"; _btnDelete.ImageIndex = 2; _btnCancel = new NavigatorCustomButton(); _btnCancel = EmbeddedNavigator.Buttons.CustomButtons.Add(); _btnCancel.Tag = "cancel"; //btn_cancel.Hint = "取消"; _btnCancel.ImageIndex = 3; } if (ShowCustomRowHeightButton) { var btnRowHeight = EmbeddedNavigator.Buttons.CustomButtons.Add(); btnRowHeight.Tag = "rowHeight"; // btnRowHeight.Hint = "行高"; btnRowHeight.ImageIndex = 4; } } catch { // ignored } }
/// <summary> /// 设置表格控件的布局. 比如按钮设置. /// </summary> public static void SetGridControlLayout(GridControl grid, bool allowEdit) { ControlNavigatorButtons btns = grid.EmbeddedNavigator.Buttons; grid.BeginInit(); grid.EmbeddedNavigator.ButtonStyle = BorderStyles.Office2003; grid.UseEmbeddedNavigator = true; btns.Append.Visible = false; btns.CancelEdit.Visible = false; btns.Edit.Visible = false; btns.Remove.Visible = false; btns.EndEdit.Visible = false; btns.NextPage.Visible = false; btns.PrevPage.Visible = false; ((GridView)grid.Views[0]).OptionsBehavior.Editable = allowEdit; //允许编辑状态 if (allowEdit)//增加两个自定义按钮(ADD,INSERT,DELETE) { ImageList img = new ImageList(); img.Images.Add(Globals.LoadImage("16_Add.ico")); img.Images.Add(Globals.LoadImage("16_Insert.ico")); img.Images.Add(Globals.LoadImage("16_Delete.ico")); grid.EmbeddedNavigator.Buttons.ImageList = img; btns.CustomButtons.Clear(); NavigatorCustomButton btnDtlAdd = new NavigatorCustomButton((int)DetailButtons.Add, "新增记录"); NavigatorCustomButton btnDtlInsert = new NavigatorCustomButton((int)DetailButtons.Insert, "插入记录"); NavigatorCustomButton btnDtlDelete = new NavigatorCustomButton((int)DetailButtons.Delete, "删除记录"); btns.CustomButtons.AddRange(new NavigatorCustomButton[] { btnDtlAdd, btnDtlInsert, btnDtlDelete }); } grid.EndInit(); }
private void AddCustomButton() { imageList = new ImageList(); imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; imageList.ImageSize = new System.Drawing.Size(11, 11); imageList.TransparentColor = System.Drawing.Color.Transparent; imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.First); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.Prev); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.Next); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.Last); #region Button_First btnFirst = new NavigatorCustomButton(0, "Trang đầu"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; btnFirst.Tag = "FirstPage"; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[]{btnFirst}); #endregion #region Button_Prev btnPrev = new NavigatorCustomButton(1, "Trang trước"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; btnPrev.Tag = "PrevPage"; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btnPrev }); #endregion #region Button_Next btnNext = new NavigatorCustomButton(2, "Trang kế"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btnNext }); btnNext.Tag = "NextPage"; #endregion #region Button_Last btnLast = new NavigatorCustomButton(3, "Trang cuối"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btnLast }); btnLast.Tag = "LastPage"; #endregion }
private void AddCustomButton() { imageList = new ImageList(); imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; imageList.ImageSize = new System.Drawing.Size(11, 11); imageList.TransparentColor = System.Drawing.Color.Transparent; imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.First); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.Prev); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.Next); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.Last); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.add); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.edit); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.delete); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.save); imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.nosave); //Refresh imageList.Images.Add(global::ProtocolVN.Framework.Win.Properties.Resources.nosave); #region Button_First btnFirst = new NavigatorCustomButton(0,"Trang đầu"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; btnFirst.Tag = "FirstPage"; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[]{btnFirst}); #endregion #region Button_Prev btnPrev = new NavigatorCustomButton(1,"Trang trước"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; btnPrev.Tag = "PrevPage"; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btnPrev }); #endregion #region Button_Next btnNext = new NavigatorCustomButton(2,"Trang kế"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btnNext }); btnNext.Tag = "NextPage"; #endregion #region Button_Last btnLast = new NavigatorCustomButton(3,"Trang cuối"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btnLast }); btnLast.Tag = "LastPage"; #endregion #region Refresh btnRefresh = new NavigatorCustomButton(9, "Refresh"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btnRefresh }); btnRefresh.Tag = "Refresh"; #endregion #region Button_Add btngAdd = new NavigatorCustomButton(4,"Thêm"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; btngAdd.Tag = "Add"; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btngAdd }); #endregion #region Button_Edit btngEdit = new NavigatorCustomButton(5,"Sữa"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; btngEdit.Tag = "Edit"; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btngEdit }); #endregion #region Button_Remove btngRemove = new NavigatorCustomButton(6,"Xóa"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; btngRemove.Tag = "Remove"; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btngRemove }); #endregion #region Button_EndEdit btngEndEdit = new NavigatorCustomButton(7,"Lưu"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; btngEndEdit.Tag = "EndEdit"; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btngEndEdit }); #endregion #region Button_CancelEdit btngCancelEdit = new NavigatorCustomButton(8,"Không lưu"); gridControl.EmbeddedNavigator.Buttons.ImageList = imageList; btngCancelEdit.Tag = "CancelEdit"; gridControl.EmbeddedNavigator.Buttons.CustomButtons.AddRange(new NavigatorCustomButton[] { btngCancelEdit }); #endregion }