"开放"的按钮打开文件的对话中使用的某些windows的应用程序包括下箭头用一个的列表,另外的选项--即"打开..".

我还没有看到这种在每一个windows的应用程序,所以你可能要试几得到它,但是SQL服务器的管理工作室和Visual Studio2005年将显示按那种方式如果你去的菜单中选择 文件>打开->文件...

我想用一个按钮这样一个建立在名单中我的一个应用,但是我不能找到控制,他们正在使用的任何地方在visual studio.我应该澄清的是,我在找具体的按钮,不是整个的对话。任何想法?

有帮助吗?

解决方案

我用拖动搜索间谍++(安装VS)来看拆分开按钮在该文件的公开对话的VS。

这表明,这是一个普通的窗按钮,一个风格,其中包括bs_defsplitbutton样式.这是一个魔法的关键词,这让你一些有趣的地方,包括

http://www.codeplex.com/windowsformsaero/SourceControl/FileView.aspx?itemId=212902&changeSetId=9930

和这里

http://msdn.microsoft.com/en-us/library/bb775949.aspx#using_splits

希望这可以帮助你。

编辑:

实际上我只是想这码从更它并创造一个分裂的按钮-但你必须确保已设定的按钮是FlatStyle到的"系统"而不是"标准"这是默认。我没有打扰到挂钩的事件处理的东西滴下来,但这是盖在MSDN链接,我想。

当然,这是Vista的仅仅是(但并不需要航空启用的,尽管名称上更)-如果你需要早期的操作系统的支持,你会回来绘制它自己。

其他提示

我记得, Ketarin 有一个按钮那样。

使用 反射器 我发现伟大的开放源控制所谓 wyDay.SplitButton. wyDay.SplitButton

我觉得你在找什么叫toolStripSplitButton.它只是提供一个工具条.但你可以添加一个toolStripContainer上的任何地方的形式和随后把该工具条和toolStripSplitButton在你的容器。

你不会想要显示掌握所以你就想要设置你的gripMargin=0.你可以自动调整大小=true以便该工具条符合你的按钮。按钮将只是看起来像一个正常的按钮的(除分割的一部分)关于您的形式。

我不熟悉使用这些,但是尝试找msdn splitbutton或dropdownbutton.我认为那些类似于你在找什么。

这是我的分按钮执行情况。它不提请箭,以及重点/unfocus行为是一个小小的不同。

这两种矿和原件处理些风格,很好看航空。

基于上 http://wyday.com/splitbutton/

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.Drawing;
using System.ComponentModel;
using System.Diagnostics;

// Original: http://blogs.msdn.com/jfoscoding/articles/491523.aspx
// Wyatt's fixes: http://wyday.com/splitbutton/
// Trimmed down and redone significantly from that version (Nick 5/6/08)
namespace DF
{
    public class SplitButton : Button
    {
        private ContextMenuStrip m_SplitMenu = null;
        private const int SplitSectionWidth = 14;
        private static int BorderSize = SystemInformation.Border3DSize.Width * 2;
        private bool mBlockClicks = false;
        private Timer mTimer;

        public SplitButton()
        {
            this.AutoSize = true;
            mTimer = new Timer();
            mTimer.Interval = 100;
            mTimer.Tick += new EventHandler(mTimer_Tick);
        }

        private void mTimer_Tick(object sender, EventArgs e)
        {
            mBlockClicks = false;
            mTimer.Stop();
        }

        #region Properties
        [DefaultValue(null)]
        public ContextMenuStrip SplitMenu
        {
            get
            {
                return m_SplitMenu;
            }
            set
            {
                if (m_SplitMenu != null)
                    m_SplitMenu.Closing -= 
                        new ToolStripDropDownClosingEventHandler(m_SplitMenu_Closing);

                m_SplitMenu = value;

                if (m_SplitMenu != null)
                    m_SplitMenu.Closing += 
                        new ToolStripDropDownClosingEventHandler(m_SplitMenu_Closing);
            }
        }

        private void m_SplitMenu_Closing(object sender, ToolStripDropDownClosingEventArgs e)
        {
            HideContextMenuStrip();
            // block click events for 0.5 sec to prevent re-showing the menu

        }

        private PushButtonState _state;
        private PushButtonState State
        {
            get
            {
                return _state;
            }
            set
            {
                if (!_state.Equals(value))
                {
                    _state = value;
                    Invalidate();
                }
            }
        }

        #endregion Properties

        protected override void OnEnabledChanged(EventArgs e)
        {
            if (Enabled)
                State = PushButtonState.Normal;
            else
                State = PushButtonState.Disabled;

            base.OnEnabledChanged(e);
        }

        protected override void OnMouseClick(MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
                return;
            if (State.Equals(PushButtonState.Disabled))
                return;
            if (mBlockClicks)
                return;

            if (!State.Equals(PushButtonState.Pressed))
                ShowContextMenuStrip();
            else
                HideContextMenuStrip();
        }

        protected override void OnMouseEnter(EventArgs e)
        {
            if (!State.Equals(PushButtonState.Pressed) && !State.Equals(PushButtonState.Disabled))
            {
                State = PushButtonState.Hot;
            }
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            if (!State.Equals(PushButtonState.Pressed) && !State.Equals(PushButtonState.Disabled))
            {
                if (Focused)
                {
                    State = PushButtonState.Default;
                }

                else
                {
                    State = PushButtonState.Normal;
                }
            }
        }

        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);

            Graphics g = pevent.Graphics;
            Rectangle bounds = this.ClientRectangle;

            // draw the button background as according to the current state.
            if (State != PushButtonState.Pressed && IsDefault && !Application.RenderWithVisualStyles)
            {
                Rectangle backgroundBounds = bounds;
                backgroundBounds.Inflate(-1, -1);
                ButtonRenderer.DrawButton(g, backgroundBounds, State);

                // button renderer doesnt draw the black frame when themes are off =(
                g.DrawRectangle(SystemPens.WindowFrame, 0, 0, bounds.Width - 1, bounds.Height - 1);
            }
            else
            {
                ButtonRenderer.DrawButton(g, bounds, State);
            }

            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            g.DrawString(Text, Font, SystemBrushes.ControlText, bounds, format);
        }

        private void ShowContextMenuStrip()
        {
            State = PushButtonState.Pressed;
            if (m_SplitMenu != null)
            {
                m_SplitMenu.Show(this, new Point(0, Height), ToolStripDropDownDirection.BelowRight);
            }
        }

        private void HideContextMenuStrip()
        {
            State = PushButtonState.Normal;
            m_SplitMenu.Hide();
            mBlockClicks = true;
            mTimer.Start();
        }
    }
}

我不认为有内在的控制,可以这样做。网。我闲逛MSDN文件的标准窗按钮控制,但是它看起来并不像它的存在。

我没有找到一个 代码项目的文章 一个自定义的执行情况;这可能有点帮助。

因为我发现的控制在窗户本身,我希望能找到它的内置在某个地方已经让我没有添加任何东西,我的代码可以使用它。但分裂的按钮 这个链接 (找到通过msdn建议)看起来很有前途的。

我会试试以后我自己,但我不知道它是如何以及处理些风格。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top