gpt4 book ai didi

winforms - 如何使用上下文菜单关闭项禁用 KryptonPage 的删除按钮?

转载 作者:行者123 更新时间:2023-12-05 06:22:37 26 4
gpt4 key购买 nike

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

我正在使用 https://github.com/ComponentFactory/KryptonVisual Studio 2015 社区赢 10

有关于我的代码的详细信息,便于理解

以下截图是表单设计器关于使用控件 screenshot of Form designer using controls 1

screenshot of Form designer using controls 2

以下是破坏应用程序的屏幕截图 application ruining time for close menu item for block i want it

有我的表单代码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;
}

}

请帮忙关闭氪金页面

最佳答案

我刚遇到同样的问题。我可以看到这个问题是 answered here

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

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

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;
}

关于winforms - 如何使用上下文菜单关闭项禁用 KryptonPage 的删除按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59103645/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com