private void OpenForm(DevExpress.XtraEditors.XtraForm xtraForm) { if (xtraForm != null) { xtraForm.MdiParent = this; xtraForm.Show(); } }
private void barButtonItem5_ItemClick(object sender, ItemClickEventArgs e) { if (subFrmQuanLyHocVien != null) { subFrmQuanLyHocVien.Close(); } subFrmQuanLyHocVien = new LapBienLaiThuHocPhi(); subFrmQuanLyHocVien.MdiParent = this; subFrmQuanLyHocVien.Show(); }
private void barButtonItem4_ItemClick(object sender, ItemClickEventArgs e) { if (subFrmQuanLyHocVien != null) { subFrmQuanLyHocVien.Close(); } subFrmQuanLyHocVien = new TraCuuHocVien(); subFrmQuanLyHocVien.MdiParent = this; subFrmQuanLyHocVien.Show(); }
// Tra cuu khoa hoc private void barButtonItem18_ItemClick(object sender, ItemClickEventArgs e) { if (subFrmQuanLyGiangDay != null) { subFrmQuanLyGiangDay.Hide(); } subFrmQuanLyGiangDay = new TraCuuKhoaHoc(); subFrmQuanLyGiangDay.MdiParent = this; subFrmQuanLyGiangDay.Show(); }
// nhap lop hoc moi private void barButtonItem15_ItemClick(object sender, ItemClickEventArgs e) { if (subFrmQuanLyGiangDay != null) { subFrmQuanLyGiangDay.Hide(); } subFrmQuanLyGiangDay = new NhapLopHocMoi(); subFrmQuanLyGiangDay.MdiParent = this; subFrmQuanLyGiangDay.Show(); }
// Danh sach luong giang vien private void barButtonItem14_ItemClick(object sender, ItemClickEventArgs e) { if (subFrmQuanLyGiangDay != null) { subFrmQuanLyGiangDay.Hide(); } subFrmQuanLyGiangDay = new DanhSachLuongGiangVien(); subFrmQuanLyGiangDay.MdiParent = this; subFrmQuanLyGiangDay.Show(); }
// Nhap giang vien private void barButtonItem12_ItemClick(object sender, ItemClickEventArgs e) { if (subFrmQuanLyGiangDay != null) { subFrmQuanLyGiangDay.Close(); } subFrmQuanLyGiangDay = new NhapGiangVien(); subFrmQuanLyGiangDay.MdiParent = this; subFrmQuanLyGiangDay.Show(); }
private void CreateMdiForm(DevExpress.XtraEditors.XtraForm form) { if (SessionHelper.member.FormPermId == 888 || SessionHelper.member.FormPermId == 999) { form.MdiParent = this; form.Show(); form.BringToFront(); } else { DevExpress.XtraEditors.XtraMessageBox.Show("Yetkiniz Bulunmuyor", "Uyarı", MessageBoxButtons.OK); } }
private void TerminalItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { DevExpress.XtraEditors.XtraForm newMDIChild = new DevExpress.XtraEditors.XtraForm(); newMDIChild.MdiParent = this; newMDIChild.Tag = 888; newMDIChild.Show(); newMDIChild.Text = e.Item.Caption + " (" + Company.GetCurrCompany().CompanyName + ")"; ucMain uc = new ucMain(); uc.Size = newMDIChild.Size; uc.Dock = DockStyle.Fill; string keep = this.Text; uc.Parent = newMDIChild; tabbedView1.AddDocument(newMDIChild); this.Text = keep; }
internal static void IsOpenForm(DevExpress.XtraEditors.XtraForm p) { try { foreach (System.Windows.Forms.Form item in System.Windows.Forms.Application.OpenForms) { if (item.Name.Equals(p.Name)) { item.Activate(); p.Dispose(); return; } } p.Show(); } catch (Exception ex) { Commons.Status(Commons.GetErrorCode("CMN", 21) + ex.Message); } }
/// Tạo thêm tab mới /// <param name="tabControl">Tên TabControl để add thêm tabpage mới vào</param> /// <param name="Text">Tiêu đề tabpage mới</param> /// <param name="Name">Tên tabpage mới</param> /// <param name="form">Tên form con của tab mới</param> /// <param name="imageIndex">index của icon</param> public static void TaoTabForm(DevExpress.XtraTab.XtraTabControl tabControl, string Text, string Name, DevExpress.XtraEditors.XtraForm form, int imageIndex) { int index = KiemTraTonTai(tabControl, Name); if (index >= 0) { tabControl.SelectedTabPage = tabControl.TabPages[index]; tabControl.SelectedTabPage.Text = Text; } else { DevExpress.XtraTab.XtraTabPage tabpage = new DevExpress.XtraTab.XtraTabPage { Text = Text, Name = Name, ImageIndex = imageIndex }; tabControl.TabPages.Add(tabpage); tabControl.SelectedTabPage = tabpage; form.TopLevel = false; form.Parent = tabpage; form.Show(); form.Dock = DockStyle.Fill; } }
private static void ShowDevGridView(DataTable dataTable, string displayName, Control parent, Point point, Size size, EventHandler eventHandle, bool multiSelect, bool autoCalPoint, DataGridViewCellPaintingEventHandler cellPaintingEventHandle, ContextMenuForm contextMenuForm) { _callControl = parent; DevExpress.XtraGrid.GridControl gridControl = new DevExpress.XtraGrid.GridControl(); DevExpress.XtraGrid.Views.Grid.GridView dataGridView = new DevExpress.XtraGrid.Views.Grid.GridView(); gridControl.MainView = dataGridView; dataGridView.OptionsView.ShowColumnHeaders = false; dataGridView.OptionsView.ShowGroupPanel = false; dataGridView.OptionsView.ShowIndicator = false; //dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //dataGridView.ColumnHeadersHeight = 18; //dataGridView.BackgroundColor = dataGridView.DefaultCellStyle.BackColor; //dataGridView.CellPainting += cellPaintingEventHandle; //dataGridView.CellPainting += new DataGridViewCellPaintingEventHandler(dataGridView_CellPainting); //dataGridView.GridColor = dataGridView.BackgroundColor; dataGridView.KeyPress += new KeyPressEventHandler(dataGridView_KeyPress); dataGridView.OptionsBehavior.ReadOnly = true; dataGridView.Tag = eventHandle; //DevExpress.XtraGrid.Columns.GridColumn column = dataGridView.Columns.Add(); //column.FieldName = //"字典选择器", "字典选择器"); //dataGridView.AllowUserToResizeRows = false; //dataGridView.AllowUserToResizeColumns = false; //dataGridView.ScrollBars = ScrollBars.Vertical; //dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //dataGridView.Cursor = Cursors.Hand; string[] displayNames = null; string ddd = displayName; if (displayName != null) { displayNames = displayName.Split(new char[] { ',', ';' }); for (int i = 0; i < displayNames.Length; i++) { DevExpress.XtraGrid.Columns.GridColumn column = dataGridView.Columns.Add(); column.FieldName = displayNames[i]; column.OptionsColumn.AllowEdit = false; column.OptionsFilter.AllowAutoFilter = false; column.OptionsFilter.AllowFilter = false; column.Visible = true; column.VisibleIndex = 0; if (i == 0) { ddd = displayNames[i]; } } } _displayNames = displayNames; SetDataGridViewList(dataGridView, TransTable(dataTable, ddd)); //dataGridView.Resize += new EventHandler(delegate(object sender1, EventArgs e1) //{ // for (int i = 0; i < dataGridView.Columns.Count - 1; i++) // { // dataGridView.Columns[i].Width = 120; // } // int width = dataGridView.Width - 120 * (dataGridView.Columns.Count - 1); // if (width < 1) // { // dataGridView.Columns[dataGridView.Columns.Count - 1].Visible = false; // } // else // { // dataGridView.Columns[dataGridView.Columns.Count - 1].Width = width; // } //}); //dataGridView.CellDoubleClick += new DataGridViewCellEventHandler(delegate(object sender, DataGridViewCellEventArgs e) //{ // if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index >= 0) // { // if (eventHandle != null) // { // if (multiSelect) // { // List<int> selectedIndexes = new List<int>(); // foreach (DataGridViewCell cell in dataGridView.SelectedCells) // { // selectedIndexes.Add(_showListItems[cell.RowIndex].Index); // } // selectedIndexes.Reverse(); // eventHandle(selectedIndexes.ToArray(), null); // if (dataGridView.Parent != null && dataGridView.Parent is DevExpress.XtraEditors.XtraForm) // { // (dataGridView.Parent as DevExpress.XtraEditors.XtraForm).Close(); // } // dataGridView.Dispose(); // } // } // } //}); dataGridView.KeyDown += new KeyEventHandler(dataGridView_KeyDown); if (!multiSelect) { //dataGridView.MouseMove += new MouseEventHandler(delegate(object sender, MouseEventArgs e) //{ // int rowIndex = dataGridView.get .HitTest(e.X, e.Y).RowIndex; // if (rowIndex >= 0) // { // dataGridView.CurrentCell = dataGridView.Rows[rowIndex].Cells[0]; // } //}); //dataGridView.CellClick += new DataGridViewCellEventHandler(delegate(object sender, DataGridViewCellEventArgs e) dataGridView.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(delegate(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { if (eventHandle != null) { eventHandle(dataGridView.GetDataRow(e.RowHandle), e); } try { if (gridControl.Parent != null && gridControl.Parent is DevExpress.XtraEditors.XtraForm) { (gridControl.Parent as DevExpress.XtraEditors.XtraForm).Close(); } dataGridView.Dispose(); gridControl.Dispose(); } catch { } }); } if (size.Width < 100) { size.Width = 100; } //dataGridView.CellMouseDown += new DataGridViewCellMouseEventHandler(dataGridView_CellMouseDown); //dataGridView.CellMouseMove += new DataGridViewCellMouseEventHandler(dataGridView_CellMouseMove); //dataGridView.CellMouseUp += new DataGridViewCellMouseEventHandler(dataGridView_CellMouseUp); DevExpress.XtraEditors.XtraForm form = new DevExpress.XtraEditors.XtraForm(); form.TopMost = true; form.StartPosition = FormStartPosition.Manual; form.Location = parent.PointToScreen(point); form.Size = size; if (parent != null && !(parent is DataGridView)) { form.Width = parent.Width; } form.Controls.Add(gridControl); gridControl.Dock = DockStyle.Fill; form.Deactivate += new EventHandler(form_Deactivate); form.FormBorderStyle = FormBorderStyle.None; if (form.Bottom > Screen.PrimaryScreen.Bounds.Height) { if (form.Top >= form.Height) { form.Top -= form.Height; } else { form.Top = 0; } } form.Width = size.Width; form.Show(); }
private static void ShowDataGridView(IEnumerable list, string displayName, Control parent, Point point, Size size, EventHandler eventHandle, bool multiSelect, bool autoCalPoint, DataGridViewCellPaintingEventHandler cellPaintingEventHandle, ContextMenuForm contextMenuForm) { _callControl = parent; DataGridView dataGridView = new DataGridView(); dataGridView.ColumnHeadersVisible = false; dataGridView.RowHeadersVisible = false; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dataGridView.ColumnHeadersHeight = 18; dataGridView.BackgroundColor = dataGridView.DefaultCellStyle.BackColor; dataGridView.CellPainting += cellPaintingEventHandle; dataGridView.CellPainting += new DataGridViewCellPaintingEventHandler(dataGridView_CellPainting); dataGridView.GridColor = dataGridView.BackgroundColor; dataGridView.KeyPress += new KeyPressEventHandler(dataGridView_KeyPress); dataGridView.ReadOnly = true; dataGridView.AllowUserToAddRows = false; dataGridView.AllowUserToDeleteRows = false; dataGridView.Columns.Add("字典选择器", "字典选择器"); dataGridView.AllowUserToResizeRows = false; dataGridView.AllowUserToResizeColumns = false; dataGridView.ScrollBars = ScrollBars.Vertical; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView.Cursor = Cursors.Hand; string[] displayNames = null; if (displayName != null) { displayNames = displayName.Split(new char[] { ',', ';' }); for (int i = 1; i < displayNames.Length; i++) { dataGridView.Columns.Add("Column" + i.ToString(), "Column"); } if (dataGridView.Columns.Count > 1) { dataGridView.ScrollBars = ScrollBars.Both; } } _displayNames = displayNames; GenListItems(); SetDataGridViewList(dataGridView); dataGridView.Resize += new EventHandler(delegate(object sender1, EventArgs e1) { for (int i = 0; i < dataGridView.Columns.Count - 1; i++) { //dataGridView.Columns[i].Width = 120; dataGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; } //Modify by wenpei.x@2014-02-12 //新增人员选择下拉框显示User_ID,故宽度不应该再有限制 if (dataGridView.Columns.Count <= 1) { int width = dataGridView.Width - 120 * (dataGridView.Columns.Count - 1); if (width < 1) { dataGridView.Columns[dataGridView.Columns.Count - 1].Visible = false; } else { dataGridView.Columns[dataGridView.Columns.Count - 1].Width = width; } } }); dataGridView.CellDoubleClick += new DataGridViewCellEventHandler(delegate(object sender, DataGridViewCellEventArgs e) { if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index >= 0) { if (eventHandle != null) { if (multiSelect) { List <int> selectedIndexes = new List <int>(); foreach (DataGridViewCell cell in dataGridView.SelectedCells) { selectedIndexes.Add(_showListItems[cell.RowIndex].Index); } selectedIndexes.Reverse(); eventHandle(selectedIndexes.ToArray(), null); if (dataGridView.Parent != null && dataGridView.Parent is DevExpress.XtraEditors.XtraForm) { (dataGridView.Parent as DevExpress.XtraEditors.XtraForm).Close(); } dataGridView.Dispose(); } } } }); dataGridView.KeyDown += new KeyEventHandler(delegate(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index >= 0) { if (eventHandle != null) { if (multiSelect) { List <int> selectedIndexes = new List <int>(); foreach (DataGridViewCell cell in dataGridView.SelectedCells) { selectedIndexes.Add(_showListItems[cell.RowIndex].Index); } selectedIndexes.Reverse(); eventHandle(selectedIndexes.ToArray(), null); } else { eventHandle(_showListItems[dataGridView.CurrentRow.Index].Index, null); } } if (dataGridView.Parent != null && dataGridView.Parent is DevExpress.XtraEditors.XtraForm) { (dataGridView.Parent as DevExpress.XtraEditors.XtraForm).Close(); } dataGridView.Dispose(); } } else if (e.KeyCode == Keys.Escape) { if (dataGridView.Parent != null && dataGridView.Parent is DevExpress.XtraEditors.XtraForm) { (dataGridView.Parent as DevExpress.XtraEditors.XtraForm).Close(); } dataGridView.Dispose(); if (_callControl != null) { _callControl.Focus(); } } }); if (!multiSelect) { dataGridView.MouseMove += new MouseEventHandler(delegate(object sender, MouseEventArgs e) { int rowIndex = dataGridView.HitTest(e.X, e.Y).RowIndex; if (rowIndex >= 0) { dataGridView.CurrentCell = dataGridView.Rows[rowIndex].Cells[0]; } }); dataGridView.CellClick += new DataGridViewCellEventHandler(delegate(object sender, DataGridViewCellEventArgs e) { if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index >= 0) { if (eventHandle != null) { eventHandle(_showListItems[dataGridView.CurrentRow.Index].Index, null); } try { if (dataGridView.Parent != null && dataGridView.Parent is DevExpress.XtraEditors.XtraForm) { (dataGridView.Parent as DevExpress.XtraEditors.XtraForm).Close(); } dataGridView.Dispose(); } catch { } } }); } if (size.Width < 100) { size.Width = 100; } dataGridView.CellMouseDown += new DataGridViewCellMouseEventHandler(dataGridView_CellMouseDown); dataGridView.CellMouseMove += new DataGridViewCellMouseEventHandler(dataGridView_CellMouseMove); dataGridView.CellMouseUp += new DataGridViewCellMouseEventHandler(dataGridView_CellMouseUp); DevExpress.XtraEditors.XtraForm form = new DevExpress.XtraEditors.XtraForm(); form.TopMost = true; form.StartPosition = FormStartPosition.Manual; form.Location = parent.PointToScreen(point); form.Size = size; //if (parent != null && !(parent is DataGridView)) //{ // form.Width = parent.Width; //} form.Controls.Add(dataGridView); dataGridView.Dock = DockStyle.Fill; form.Deactivate += new EventHandler(form_Deactivate); form.FormBorderStyle = FormBorderStyle.None; if (form.Bottom > Screen.PrimaryScreen.Bounds.Height) { if (form.Top >= form.Height) { form.Top -= form.Height; } else { form.Top = 0; } } form.Show(); //if (size.Height > dataGridView.RowTemplate.Height * dataGridView.Rows.Count + dataGridView.ColumnHeadersHeight) //{ // dataGridView.ColumnHeadersVisible = false; // Control parentControl = parent; // Dialog.SetPopup(dataGridView, parent, point, new Size(size.Width, dataGridView.RowTemplate.Height * dataGridView.Rows.Count + 3), autoCalPoint); //} //else //{ // Control parentControl = parent; // Dialog.SetPopup(dataGridView, parent, point, size, autoCalPoint); //} }
/// <summary> /// Adds the form tot the list of this.MdiChildren /// </summary> /// <param name="form"></param> public void ShowForm(DevExpress.XtraEditors.XtraForm form) { try { using (new Essential.UTL.WaitCursor()) { //Check if there is already a form of the same type open and select it //instead of opening a new one if (form is Essential.BaseList && !(form as Essential.BaseList).ForceNew) { if (form is Document.BaseDocumentList) { if (! Parallel.ForEach(this.MdiChildren.Where(n => (n as Document.BaseDocumentList) != null), (child, pls) => { if ((child as Document.BaseDocumentList).DocumentType == (form as Document.BaseDocumentList).DocumentType) { //If the List is already open select it if not the form with open this.BeginInvoke(new Action(() => child.Select())); //child.Select(); //return; pls.Break(); } }).IsCompleted) { return; } //foreach (var child in this.MdiChildren.Where(n => (n as Document.BaseDocumentList) != null)) //{ // if ((child as Document.BaseDocumentList).DocumentType == (form as Document.BaseDocumentList).DocumentType) // { // //If the List is already open select it if not the form with open // child.Select(); // return; // } //} } else if (form is Company.CompanyList) { if (! Parallel.ForEach(this.MdiChildren.Where(n => (n as Company.CompanyList) != null), (child, pls) => { if ((child as Company.CompanyList).Type == (form as Company.CompanyList).Type) { //If the List is already open select it if not the form with open this.BeginInvoke(new Action(() => child.Select())); pls.Break(); } }).IsCompleted) { return; } //foreach (var child in this.MdiChildren.Where(n => (n as Company.CompanyList) != null)) //{ // if ((child as Company.CompanyList).Type == (form as Company.CompanyList).Type) // { // //If the List is already open select it if not the form with open // child.Select(); // return; // } //} } else { if (! Parallel.ForEach(this.MdiChildren, (child, pls) => { if (child.Text == form.Text) { //If the List is already open select it if not the form with open this.BeginInvoke(new Action(() => child.Select())); pls.Break(); } }).IsCompleted) { return; } //foreach (var child in this.MdiChildren) //{ // if (child.Text == form.Text) // { // //If the List is already open select it if not the form with open // child.Select(); // return; // } //} } } form.FormClosing += form_FormClosing; form.FormClosed += form_FormClosed; form.MdiParent = MainForm.Instance; form.Show(); form.Focus(); //if (this.MdiChildren.Count() != 1) // bbiSite.Enabled = false; //if (form is CDS.Client.Desktop.Document.BaseDocument) //{ // if ((form as CDS.Client.Desktop.Document.BaseDocument).TabColor != null) // { // MdiManager.Pages[MdiManager.Pages.Count - 1].Appearance.HeaderActive.BackColor = (form as CDS.Client.Desktop.Document.BaseDocument).TabColor; // MdiManager.Pages[MdiManager.Pages.Count - 1].Appearance.HeaderDisabled.BackColor = (form as CDS.Client.Desktop.Document.BaseDocument).TabColor; // } //} } } catch (Exception ex) { if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } }