1

如何阻止KryptonPage 关闭,我需要删除停靠区域的按钮和上下文菜单选项以关闭

我正在使用https://github.com/ComponentFactory/Krypton Visual Studio 2015 Community Win 10

有关于我的代码的详细信息以便清楚理解

以下屏幕截图是有关使用控件 的表单设计器的屏幕截图 使用控件的表单设计器 1

使用控件 2 的表单设计器的屏幕截图

以下屏幕截图破坏了应用 程序应用程序破坏时间的关闭菜单项的块我想要它

有我的表单代码c#


// this is main form code

public partial class frmMain : KryptonForm
{

        public frmMain()
        {
            InitializeComponent();
            kryptonPanel1.Dock = DockStyle.Fill;
            kryptonDockableWorkspace.Dock = DockStyle.Fill;
            kryptonPanel.Dock = DockStyle.Fill;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            KryptonDockingWorkspace w = kryptonDockingManager.ManageWorkspace(kryptonDockableWorkspace);

            kryptonDockingManager.ManageControl(kryptonPanel, w);
            kryptonDockingManager.ManageFloating(this);


            kryptonDockingManager.AddDockspace("Control", DockingEdge.Left, new KryptonPage[] { NewWinTools() });
            kryptonDockingManager.AddDockspace("Control", DockingEdge.Bottom, new KryptonPage[] { NewWinTools(), NewWinTools(), NewWinTools(), NewWinTools() , NewWinTools() });

            kryptonDockingManager.AddToWorkspace("Workspace", new KryptonPage[] { NewWinControl() });


        }


        private KryptonPage NewPage(string name, int image, Control content)
        {
            // Create new page with title and image
            KryptonPage p = new KryptonPage();

            p.Text = name;
            p.TextTitle = name;
            p.TextDescription = name;
            p.ImageSmall = imageListSmall.Images[image];

            // Add the control for display inside the page
            content.Dock = DockStyle.Fill;
            p.Controls.Add(content);

            return p;
        }


        private KryptonPage NewWinControl()
        {
            UserControl1 br = new UserControl1();

            KryptonPage page = NewPage("New Tab", 0, br);

            page.ClearFlags(KryptonPageFlags.DockingAllowAutoHidden | KryptonPageFlags.DockingAllowDocked);

            return page;
        }

        private KryptonPage NewWinTools()
        {
            UserControl1 br = new UserControl1();

            KryptonPage page = NewPage("Tools 1 ", 2, br);
            page.ClearFlags( KryptonPageFlags.DockingAllowClose);

            return page;
        }

}

请帮助阻止关闭 KryptonPage

4

1 回答 1

0

我刚刚遇到了同样的问题。我可以看到这个问题在这里得到了回答

看起来没有办法真正删除关闭按钮,但您可以拦截它然后忽略该事件。

为了完整起见,这是您需要编写的代码:

private void CreateDockWorkspace()
{
    KryptonDockingWorkspace w = kryptonDockingManager.ManageWorkspace("Workspace", kryptonDockableWorkspace);
    kryptonDockingManager.ManageControl("Control", kryptonPanel, w);
    kryptonDockingManager.ManageFloating("Floating", this);

    kryptonDockingManager.AddToWorkspace("Workspace", new KryptonPage[] {
            NewPage("Overview"),
            NewPage("Main"),
            NewPage("Report"),
    });

    // This is where you wire up the CloseAction event handler
    var workspace = kryptonDockingManager.CellsWorkspace.FirstOrDefault();
    workspace.CloseAction += HandleTabCloseAction;
}

private void HandleTabCloseAction(object sender, CloseActionEventArgs e)
{
    // This event handler ignores the action
    e.Action = CloseButtonAction.None;
}

private KryptonPage NewPage(string name)
{
    var p = new KryptonPage();
    p.Text = name;
    p.TextTitle = name;
    p.TextDescription = name;

    content.Dock = DockStyle.Fill;
    p.Controls.Add(content);

    return p;
}
于 2020-01-09T16:47:18.553 回答