A button with an arrow that alternates between pointing up and down when clicked.
Наследование: System.Windows.Forms.Button
Пример #1
0
        private Int32 AddButtons(ExtendedMessageBoxButtons p_ebbButtons, bool p_booShowDetails)
        {
            Int32 intLastButtonLeft = pnlButtons.Right - 6;
            Int32 intMinimumWidth   = 6;

            //details button
            if (p_booShowDetails)
            {
                DetailsButton butDetails = new DetailsButton();
                butDetails.AutoSize     = true;
                butDetails.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                butDetails.OpenText     = "See details";
                butDetails.CloseText    = "Hide details";
                butDetails.Anchor       = AnchorStyles.Bottom | AnchorStyles.Left;
                butDetails.Location     = new Point(pnlButtons.Left + 6, 12);
                butDetails.Click       += new EventHandler(Details_Click);
                butDetails.TabIndex     = 0;
                pnlButtons.Controls.Add(butDetails);
                intMinimumWidth += butDetails.Width + 12;
            }

            //cancel button
            if ((p_ebbButtons & ExtendedMessageBoxButtons.Cancel) == ExtendedMessageBoxButtons.Cancel)
            {
                Button butCancel = new Button();
                butCancel.Text     = "Cancel";
                butCancel.Anchor   = AnchorStyles.Bottom | AnchorStyles.Right;
                butCancel.Location = new Point(intLastButtonLeft - butCancel.Width - 6, 12);
                butCancel.Click   += new EventHandler(Button_Click);
                butCancel.Tag      = DialogResult.Cancel;
                butCancel.TabIndex = 7;
                pnlButtons.Controls.Add(butCancel);
                intLastButtonLeft = butCancel.Left;
                this.CancelButton = butCancel;
                intMinimumWidth  += butCancel.Width + 6;
            }

            //no button
            if ((p_ebbButtons & ExtendedMessageBoxButtons.No) == ExtendedMessageBoxButtons.No)
            {
                Button butNo = new Button();
                butNo.Text        = "No";
                butNo.Anchor      = AnchorStyles.Bottom | AnchorStyles.Right;
                butNo.Location    = new Point(intLastButtonLeft - butNo.Width - 6, 12);
                butNo.Click      += new EventHandler(Button_Click);
                butNo.Tag         = DialogResult.No;
                butNo.TabIndex    = 6;
                intLastButtonLeft = butNo.Left;
                pnlButtons.Controls.Add(butNo);
                if ((p_ebbButtons & ExtendedMessageBoxButtons.Cancel) != ExtendedMessageBoxButtons.Cancel)
                {
                    this.CancelButton = butNo;
                }
                intMinimumWidth += butNo.Width + 6;
            }

            //yes button
            if ((p_ebbButtons & ExtendedMessageBoxButtons.Yes) == ExtendedMessageBoxButtons.Yes)
            {
                Button butYes = new Button();
                butYes.Text       = "Yes";
                butYes.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
                butYes.Location   = new Point(intLastButtonLeft - butYes.Width - 6, 12);
                butYes.Click     += new EventHandler(Button_Click);
                butYes.Tag        = DialogResult.Yes;
                butYes.TabIndex   = 5;
                intLastButtonLeft = butYes.Left;
                pnlButtons.Controls.Add(butYes);
                this.AcceptButton = butYes;
                intMinimumWidth  += butYes.Width + 6;
            }

            //ok button
            if ((p_ebbButtons & ExtendedMessageBoxButtons.OK) == ExtendedMessageBoxButtons.OK)
            {
                Button butOk = new Button();
                butOk.Text        = "OK";
                butOk.Anchor      = AnchorStyles.Bottom | AnchorStyles.Right;
                butOk.Location    = new Point(intLastButtonLeft - butOk.Width - 6, 12);
                butOk.Click      += new EventHandler(Button_Click);
                butOk.Tag         = DialogResult.OK;
                butOk.TabIndex    = 4;
                intLastButtonLeft = butOk.Left;
                pnlButtons.Controls.Add(butOk);
                this.AcceptButton = butOk;
                intMinimumWidth  += butOk.Width + 6;
            }

            //ignore button
            if ((p_ebbButtons & ExtendedMessageBoxButtons.Ignore) == ExtendedMessageBoxButtons.Ignore)
            {
                Button butIgnore = new Button();
                butIgnore.Text     = "Ignore";
                butIgnore.Anchor   = AnchorStyles.Bottom | AnchorStyles.Right;
                butIgnore.Location = new Point(intLastButtonLeft - butIgnore.Width - 6, 12);
                butIgnore.Click   += new EventHandler(Button_Click);
                butIgnore.Tag      = DialogResult.Ignore;
                butIgnore.TabIndex = 3;
                intLastButtonLeft  = butIgnore.Left;
                pnlButtons.Controls.Add(butIgnore);
                this.CancelButton = butIgnore;
                intMinimumWidth  += butIgnore.Width + 6;
            }

            //retry button
            if ((p_ebbButtons & ExtendedMessageBoxButtons.Retry) == ExtendedMessageBoxButtons.Retry)
            {
                Button butRetry = new Button();
                butRetry.Text     = "Retry";
                butRetry.Anchor   = AnchorStyles.Bottom | AnchorStyles.Right;
                butRetry.Location = new Point(intLastButtonLeft - butRetry.Width - 6, 12);
                butRetry.Click   += new EventHandler(Button_Click);
                butRetry.Tag      = DialogResult.Retry;
                butRetry.TabIndex = 2;
                intLastButtonLeft = butRetry.Left;
                pnlButtons.Controls.Add(butRetry);
                this.AcceptButton = butRetry;
                intMinimumWidth  += butRetry.Width + 6;
            }

            //abort button
            if ((p_ebbButtons & ExtendedMessageBoxButtons.Abort) == ExtendedMessageBoxButtons.Abort)
            {
                Button butAbort = new Button();
                butAbort.Text     = "Abort";
                butAbort.Anchor   = AnchorStyles.Bottom | AnchorStyles.Right;
                butAbort.Location = new Point(intLastButtonLeft - butAbort.Width - 6, 12);
                butAbort.Click   += new EventHandler(Button_Click);
                butAbort.Tag      = DialogResult.Abort;
                butAbort.TabIndex = 1;
                intLastButtonLeft = butAbort.Left;
                pnlButtons.Controls.Add(butAbort);
                this.AcceptButton = butAbort;
                intMinimumWidth  += butAbort.Width + 6;
            }

            return(intMinimumWidth);
        }
		private Int32 AddButtons(ExtendedMessageBoxButtons p_ebbButtons, bool p_booShowDetails)
		{
			Int32 intLastButtonLeft = pnlButtons.Right - 6;
			Int32 intMinimumWidth = 6;

			//details button
			if (p_booShowDetails)
			{
				DetailsButton butDetails = new DetailsButton();
				butDetails.AutoSize = true;
				butDetails.AutoSizeMode = AutoSizeMode.GrowAndShrink;
				butDetails.OpenText = "See details";
				butDetails.CloseText = "Hide details";
				butDetails.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
				butDetails.Location = new Point(pnlButtons.Left + 6, 12);
				butDetails.Click += new EventHandler(Details_Click);
				butDetails.TabIndex = 0;
				pnlButtons.Controls.Add(butDetails);
				intMinimumWidth += butDetails.Width + 12;
			}

			//cancel button
			if ((p_ebbButtons & ExtendedMessageBoxButtons.Cancel) == ExtendedMessageBoxButtons.Cancel)
			{
				Button butCancel = new Button();
				butCancel.Text = "Cancel";
				butCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
				butCancel.Location = new Point(intLastButtonLeft - butCancel.Width - 6, 12);
				butCancel.Click += new EventHandler(Button_Click);
				butCancel.Tag = DialogResult.Cancel;
				butCancel.TabIndex = 7;
				pnlButtons.Controls.Add(butCancel);
				intLastButtonLeft = butCancel.Left;
				this.CancelButton = butCancel;
				intMinimumWidth += butCancel.Width + 6;
			}

			//no button
			if ((p_ebbButtons & ExtendedMessageBoxButtons.No) == ExtendedMessageBoxButtons.No)
			{
				Button butNo = new Button();
				butNo.Text = "No";
				butNo.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
				butNo.Location = new Point(intLastButtonLeft - butNo.Width - 6, 12);
				butNo.Click += new EventHandler(Button_Click);
				butNo.Tag = DialogResult.No;
				butNo.TabIndex = 6;
				intLastButtonLeft = butNo.Left;
				pnlButtons.Controls.Add(butNo);
				if ((p_ebbButtons & ExtendedMessageBoxButtons.Cancel) != ExtendedMessageBoxButtons.Cancel)
					this.CancelButton = butNo;
				intMinimumWidth += butNo.Width + 6;
			}

			//yes button
			if ((p_ebbButtons & ExtendedMessageBoxButtons.Yes) == ExtendedMessageBoxButtons.Yes)
			{
				Button butYes = new Button();
				butYes.Text = "Yes";
				butYes.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
				butYes.Location = new Point(intLastButtonLeft - butYes.Width - 6, 12);
				butYes.Click += new EventHandler(Button_Click);
				butYes.Tag = DialogResult.Yes;
				butYes.TabIndex = 5;
				intLastButtonLeft = butYes.Left;
				pnlButtons.Controls.Add(butYes);
				this.AcceptButton = butYes;
				intMinimumWidth += butYes.Width + 6;
			}

			//ok button
			if ((p_ebbButtons & ExtendedMessageBoxButtons.OK) == ExtendedMessageBoxButtons.OK)
			{
				Button butOk = new Button();
				butOk.Text = "OK";
				butOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
				butOk.Location = new Point(intLastButtonLeft - butOk.Width - 6, 12);
				butOk.Click += new EventHandler(Button_Click);
				butOk.Tag = DialogResult.OK;
				butOk.TabIndex = 4;
				intLastButtonLeft = butOk.Left;
				pnlButtons.Controls.Add(butOk);
				this.AcceptButton = butOk;
				intMinimumWidth += butOk.Width + 6;
			}

			//ignore button
			if ((p_ebbButtons & ExtendedMessageBoxButtons.Ignore) == ExtendedMessageBoxButtons.Ignore)
			{
				Button butIgnore = new Button();
				butIgnore.Text = "Ignore";
				butIgnore.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
				butIgnore.Location = new Point(intLastButtonLeft - butIgnore.Width - 6, 12);
				butIgnore.Click += new EventHandler(Button_Click);
				butIgnore.Tag = DialogResult.Ignore;
				butIgnore.TabIndex = 3;
				intLastButtonLeft = butIgnore.Left;
				pnlButtons.Controls.Add(butIgnore);
				this.CancelButton = butIgnore;
				intMinimumWidth += butIgnore.Width + 6;
			}

			//retry button
			if ((p_ebbButtons & ExtendedMessageBoxButtons.Retry) == ExtendedMessageBoxButtons.Retry)
			{
				Button butRetry = new Button();
				butRetry.Text = "Retry";
				butRetry.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
				butRetry.Location = new Point(intLastButtonLeft - butRetry.Width - 6, 12);
				butRetry.Click += new EventHandler(Button_Click);
				butRetry.Tag = DialogResult.Retry;
				butRetry.TabIndex = 2;
				intLastButtonLeft = butRetry.Left;
				pnlButtons.Controls.Add(butRetry);
				this.AcceptButton = butRetry;
				intMinimumWidth += butRetry.Width + 6;
			}

			//abort button
			if ((p_ebbButtons & ExtendedMessageBoxButtons.Abort) == ExtendedMessageBoxButtons.Abort)
			{
				Button butAbort = new Button();
				butAbort.Text = "Abort";
				butAbort.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
				butAbort.Location = new Point(intLastButtonLeft - butAbort.Width - 6, 12);
				butAbort.Click += new EventHandler(Button_Click);
				butAbort.Tag = DialogResult.Abort;
				butAbort.TabIndex = 1;
				intLastButtonLeft = butAbort.Left;
				pnlButtons.Controls.Add(butAbort);
				this.AcceptButton = butAbort;
				intMinimumWidth += butAbort.Width + 6;
			}

			return intMinimumWidth;
		}