|
1. form 設(shè)置為 private 始終 只打開(kāi)一個(gè)
2.NavBarControl嘗試設(shè)置Item的屬性LargeImageIndex的值,則發(fā)現(xiàn)沒(méi)有任何變化,這是為什么呢?原來(lái)在設(shè)置這個(gè)屬性之前還需要設(shè)置此Item所在Group的屬性GroupStyle的值為L(zhǎng)argeImageText。
3. xtraTabbedMdiManager1.SelectedPage = xtraTabbedMdiManager1.Pages[f1]; // 選中page
xtraTabbedMdiManager1.Pages[f1].Image = navBarItem1.SmallImage;// page設(shè)置圖片
this.xtraTabbedMdiManager1.ClosePageButtonShowMode = DevExpress.XtraTab.ClosePageButtonShowMode.InAllTabPagesAndTabControlHeader;
4. 雙擊保存
using DevExpress.XtraTabbedMdi;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication15
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
xtraTabbedMdiManager1.MdiParent = this;
}
private void navBarControl1_Click(object sender, EventArgs e)
{
Form2 f1 = Form2.CreateFrom();
f1.MdiParent = this;
f1.Show();
xtraTabbedMdiManager1.SelectedPage = xtraTabbedMdiManager1.Pages[f1];
xtraTabbedMdiManager1.Pages[f1].Image = navBarItem1.SmallImage;
}
private void navBarItem2_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
{
Form3 f1 = Form3.CreateForm();
f1.MdiParent = this;
f1.Show();
xtraTabbedMdiManager1.SelectedPage = xtraTabbedMdiManager1.Pages[f1];
xtraTabbedMdiManager1.Pages[f1].Image = navBarItem1.SmallImage;
}
private DateTime m_LastClick = System.DateTime.Now;
private XtraMdiTabPage m_lastPage = null;
private void xtraTabbedMdiManager1_MouseDown(object sender, MouseEventArgs e)
{
XtraMdiTabPage curPage = (sender as XtraTabbedMdiManager).SelectedPage;
if (e.Button == MouseButtons.Left)
{
DateTime dt = DateTime.Now;
TimeSpan span = dt.Subtract(m_LastClick);
if (span.TotalMilliseconds < 300) //如果兩次點(diǎn)擊的時(shí)間間隔小于300毫秒,則認(rèn)為是雙擊
{
if (this.MdiChildren.Length > 1)
{
// 限制只有在同一個(gè)頁(yè)簽上雙擊才能關(guān)閉.(規(guī)避兩個(gè)頁(yè)簽切換時(shí)點(diǎn)太快導(dǎo)致意外關(guān)閉頁(yè)簽)
if (curPage.Equals(m_lastPage))
{
//if (this.ActiveMdiChild != m_MapForm)
//{
//this.ActiveMdiChild.Close();
curPage.MdiChild.Close();
//}
}
}
m_LastClick = dt.AddMinutes(-1);
}
else
{
m_LastClick = dt;
m_lastPage = curPage;
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
/*************/ form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication15
{
public partial class Form2 : Form
{
private Form2()
{
InitializeComponent();
}
private static Form2 instance;
public static Form2 CreateFrom()
{
//判斷是否存在該窗體,或時(shí)候該字窗體是否被釋放過(guò),如果不存在該窗體,則 new 一個(gè)字窗體
if (instance == null || instance.IsDisposed)
{
instance = new Form2();
}
return instance;
}
private void Form2_Load(object sender, EventArgs e)
{
}
}
}
|