ToolStripManager 不工作

发布于 2024-07-14 18:58:38 字数 600 浏览 6 评论 0原文

ToolStripManager 已彻底损坏。 LoadSettings 没有做任何事情...而且我显然不是唯一遇到此问题的人:

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/656f5332-610d-42c3-ae2d-0ffb84a74b34/

https://connect.microsoft.com/VisualStudio/ Feedback/ViewFeedback.aspx?FeedbackID=128042

那么...有人有解决方法吗? 该线程中发布的内容只是将所有工具栏移至窗口底部。

The ToolStripManager is hopelessly broken. LoadSettings doesn't do a thing...and I'm evidently not the only one with this problem:

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/656f5332-610d-42c3-ae2d-0ffb84a74b34/

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=128042

So...anyone have a workaround? The one posted in that thread just moved all the toolbars to the bottom of the window.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏日落 2024-07-21 18:58:38

这是我的解决方案:

声明此结构来存储工具栏的设置:

[Serializable]
public struct ToolStripSettings
{
    public bool Visible;
    public Point Location;
}

用于保存的代码

// save toolbar settings
List<ToolStripSettings> toolSettings = new List<ToolStripSettings>();
// mToolbars is initialized in the constructor to contain all of your toolbar members
// you could also probably populate it with reflection
foreach (ToolStrip ts in mToolbars)
{
    ToolStripSettings tss = new ToolStripSettings();
    tss.Visible = ts.Visible;
    tss.Location = ts.Location;
    toolSettings.Add(tss);
}
// serialize the toolSettings list wherever you keep the 
// rest of your user-specific settings

用于恢复的代码

// Load toolstrip settings, if any
if (/*deserialized storage location*/ != null)
{
    for (int i = 0; i < mToolbars.Length; i++)
    {
        mToolbars[i].Visible = /*deserialized storage location*/[i].Visible;
        mToolbars[i].Location = /*deserialized storage location*/[i].Location;
    }
}

Here is my solution:

Declare this struct to store the settings of a toolbar:

[Serializable]
public struct ToolStripSettings
{
    public bool Visible;
    public Point Location;
}

Code to save

// save toolbar settings
List<ToolStripSettings> toolSettings = new List<ToolStripSettings>();
// mToolbars is initialized in the constructor to contain all of your toolbar members
// you could also probably populate it with reflection
foreach (ToolStrip ts in mToolbars)
{
    ToolStripSettings tss = new ToolStripSettings();
    tss.Visible = ts.Visible;
    tss.Location = ts.Location;
    toolSettings.Add(tss);
}
// serialize the toolSettings list wherever you keep the 
// rest of your user-specific settings

Code to restore

// Load toolstrip settings, if any
if (/*deserialized storage location*/ != null)
{
    for (int i = 0; i < mToolbars.Length; i++)
    {
        mToolbars[i].Visible = /*deserialized storage location*/[i].Visible;
        mToolbars[i].Location = /*deserialized storage location*/[i].Location;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文