当前位置: 首页>>代码示例>>C#>>正文


C# Button.Focus方法代码示例

本文整理汇总了C#中System.Windows.Forms.Button.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# Button.Focus方法的具体用法?C# Button.Focus怎么用?C# Button.Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Button的用法示例。


在下文中一共展示了Button.Focus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveFocus

 public static void RemoveFocus(Control ctrl)
 {
     Button btn = new Button();
     btn.Parent = ctrl;
     btn.Left = -9999;
     btn.Top = -9999;
     btn.Focus();
     btn.Dispose();
 }
开发者ID:450640526,项目名称:HtmExplorer,代码行数:9,代码来源:System.cs

示例2: TimeToggleButton

        public TimeToggleButton()
        {
            start = (Button)FindControlByName("startTimeButton");
            stop = (Button)FindControlByName("stopTimeButton");

            start.Click += start_Click;
            stop.Click += stop_Click;

            OperateOnControl(stop, _ =>
            {
                stop.Width = start.Width = (stop.Left + stop.Width) - start.Left;
                stop.Left = start.Left;
                stop.Hide();
                start.Focus();
            });
        }
开发者ID:charliesome,项目名称:nulloader,代码行数:16,代码来源:TimeToggleButton.cs

示例3: MoveWest

        // Move West on the Grid.
        void MoveWest()
        {
            // Set the Current Room indicator.
            DisplayCurrentRoom(false);

            string strRoomName = string.Empty;
            int iNextButton = iCurrentRoom - 25;
            bool blnRoomUpdated = false;
            bool blnLinkUpdated = false;

            // ## Move Room ##
            strRoomName = "room" + iNextButton;
            Button room = new Button();
            Button hPath = new Button();

            try
            {
                // Get the Room Control and set focus.
                Control[] btnRoom = this.Controls.Find(strRoomName, true);
                if (btnRoom != null)
                {
                    room = (Button)btnRoom[0];
                }
                room.Focus();

                // If AutoMap is enabled, save the new room to the map.
                if (blnAutoMap)
                {
                    if (room.BackColor != clrCurrent)
                    {
                        room.BackColor = clrCurrent;
                        blnRoomUpdated = true;
                    }

                    // If AutoMap is enabled, link the respective rooms.
                    Control[] btnHPath = this.Controls.Find("hpath" + iNextButton, true);
                    if (btnHPath != null)
                    {
                        hPath = (Button)btnHPath[0];

                        if (!hPath.Visible)
                        {
                            hPath.Visible = true;
                            blnLinkUpdated = true;
                        }
                    }
                }

                // Save the Room Location
                if (blnRoomUpdated || blnLinkUpdated)
                {
                    SaveRoom(iCurrentArea, iCurrentRoom, iCurrentX, iCurrentY, iCurrentZ, HasUpLink(iCurrentRoom), HasDownLink(iCurrentRoom));
                }

                // Set the room Details to the form.
                lblButtonName.Text = strRoomName.Replace("room", "");
                iCurrentRoom = Convert.ToInt32(strRoomName.Replace("room", ""));
                SetCurrentRoom();

                // Set new Current Room.
                iCurrentRoom = iNextButton;

                // Update the Room Zoom View for the current room.
                UpdateZoomView(room);

            }
            catch (Exception ex)
            {
                string strError = ex.Message;

                NewMap_West();
            }

            // Set the Current Room indicator.
            DisplayCurrentRoom(true);
        }
开发者ID:kerchunk,项目名称:GizMaker,代码行数:77,代码来源:Mapper.cs

示例4: MoveUp

        // Move Up to a new Grid.
        void MoveUp()
        {
            Button room = new Button();
            string strRoomName = "room" + iCurrentRoom.ToString();
            Control[] btnRoom = this.Controls.Find(strRoomName, true);

            if (btnRoom != null)
            {
                room = (Button)btnRoom[0];
                room.Focus();

                if (blnAutoMap)
                {
                    // Save the Room Location
                    SaveRoom(iCurrentArea, iCurrentRoom, iCurrentX, iCurrentY, iCurrentZ, true, HasDownLink(iCurrentRoom));
                }
            }

            NewMap_Up();
        }
开发者ID:kerchunk,项目名称:GizMaker,代码行数:21,代码来源:Mapper.cs

示例5: InPhieuKham

        private void InPhieuKham(string tenkhoa, Button button, string sokham, int isUuTien)
        {
            try
            {

                string val = "BỆNH NHÂN THƯỜNG";
                if (_QMSProperties.MaKhoaKhamBenh == "KKB")
                {
                    val = (isUuTien == 0) ? "BỆNH NHÂN THƯỜNG" : "BỆNH NHÂN ƯU TIÊN";
                }
                Utility.WaitNow(this);
                UIAction._EnableControl(button, false, "");
                DataTable dataTable = new DataTable();
                Utility.AddColumToDataTable(ref dataTable, "So_Kham", typeof(string));
                DataRow row = dataTable.NewRow();
                row["So_Kham"] = Utility.sDbnull(sokham);
                dataTable.Rows.Add(row);
                CRPT_SOKHAM crpt_sokham = new CRPT_SOKHAM();
                crpt_sokham.SetDataSource(dataTable);
                crpt_sokham.SetParameterValue("TEN_BENH_VIEN", _QMSProperties.TenBenhVien);
                string str2 = NgayIn(DateTime.Now);
                crpt_sokham.SetParameterValue("PrintDate", str2);
                crpt_sokham.SetParameterValue("TenKhoa", Utility.sDbnull(tenkhoa));
                crpt_sokham.SetParameterValue("LoaiDoiTuong", val);
                if (!string.IsNullOrEmpty(_QMSProperties.PrinterName))
                {
                    crpt_sokham.PrintOptions.PrinterName = Utility.sDbnull(_QMSProperties.PrinterName);
                }
                crpt_sokham.PrintToPrinter(1, false, 0, 0);
                UIAction._EnableControl(button, true, "");
                button.Focus();

            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi khi in số khám\n" + ex.Message);
            }
            finally
            {
                UIAction._EnableControl(cmdKhamYC, true,"");
                Utility.DefaultNow(this);
            }
        }
开发者ID:khaha2210,项目名称:CodeNewHis,代码行数:43,代码来源:frm_SoKham.cs

示例6: makeAddQuestionAndSave

        private void makeAddQuestionAndSave()
        {
            // Make a panel
            Panel addQuestionAndSavePanel = new Panel();
            addQuestionAndSavePanel.BackColor = Color.Transparent;
            addQuestionAndSavePanel.Height = 150;
            addQuestionAndSavePanel.Width = Screen.PrimaryScreen.Bounds.Width - 225;
            addQuestionAndSavePanel.Name = "addQuestionAndSavePanel#" + panelCounter.ToString();

            // Buttons are made here
            Button AddQuestionButton = new Button();
            Button Save = new Button();
            Button StartOver = new Button();
            // Combox is made here
            ComboBox questionType = new ComboBox();

            // Buttons settings
            AddQuestionButton.Location = new Point(470, 10);
            AddQuestionButton.Name = "AddQuestion#" + questionCounter.ToString();
            AddQuestionButton.Size = new Size(160, 30);
            AddQuestionButton.TabIndex = questionCounter;
            AddQuestionButton.Text = "Vraag toevoegen";
            AddQuestionButton.UseVisualStyleBackColor = true;
            AddQuestionButton.Focus();
            AddQuestionButton.Font = new Font("Segoe Print", 10F, FontStyle.Regular, GraphicsUnit.Point);
            AddQuestionButton.Click += new EventHandler(AddQuestion_Click);

            StartOver.Location = new Point(755, 10);
            StartOver.Name = "StartOver#" + questionCounter.ToString();
            StartOver.Size = new Size(160, 30);
            StartOver.TabIndex = questionCounter;
            StartOver.Text = "Overnieuw beginnen";
            StartOver.UseVisualStyleBackColor = true;
            StartOver.Font = new Font("Segoe Print", 10F, FontStyle.Regular, GraphicsUnit.Point);
            StartOver.Click += new EventHandler(StartOver_Click);

            Save.Location = new Point(935,10);
            Save.Name = "Save#" + questionCounter.ToString();
            Save.Size = new Size(90, 30);
            Save.TabIndex = questionCounter;
            Save.Text = "Opslaan";
            Save.UseVisualStyleBackColor = true;
            Save.Font = new Font("Segoe Print", 10F, FontStyle.Regular, GraphicsUnit.Point);
            Save.Click += new EventHandler(Save_Click);
            // Combobox settings
            questionType.Location = new Point(300, 10);
            questionType.Name = "questionType#" + questionCounter.ToString();
            questionType.Font = new Font("Segoe Print", 10F, FontStyle.Bold, GraphicsUnit.Point);
            questionType.DropDownStyle = ComboBoxStyle.DropDownList;
            questionType.Size = new Size(150, 30);
            questionType.DropDownWidth = 150;
            questionType.Items.Add("Open vraag");
            questionType.Items.Add("Stelling");
            questionType.Items.Add("Multiple choice (2)");
            questionType.Items.Add("Multiple choice (3)");
            questionType.Items.Add("Multiple choice (4)");
            questionType.Items.Add("Multiple choice (5)");
            questionType.Items.Add("Multiple choice (6)");
            questionType.SelectedItem = "Open vraag";

            // Add buttons to addQuestionAndSavePanel
            addQuestionAndSavePanel.Controls.Add(AddQuestionButton);
            addQuestionAndSavePanel.Controls.Add(Save);
            addQuestionAndSavePanel.Controls.Add(StartOver);
            addQuestionAndSavePanel.Controls.Add(questionType);

            questionFlowPanel.Controls.Add(addQuestionAndSavePanel);

            panelCounter++;
        }
开发者ID:kevinassen1992,项目名称:KBS2,代码行数:70,代码来源:CreateQuestionView.cs

示例7: FocusTest

		public void FocusTest ()
		{
			Form f = null;
			Button c = null, d = null;

			try {
				f = new Form ();
				f.ShowInTaskbar = false;
				f.Visible = true;
				c = new Button ();
				c.Visible = true;
				f.Controls.Add (c);

				d = new Button ();
				d.Visible = false;
				f.Controls.Add (d);

				Assert.IsTrue (c.CanFocus, "Focus1");
				Assert.IsFalse (c.Focused, "Focus2");
				c.Focus ();
				Assert.IsTrue (c.Focused, "Focus3");
				d.Focus ();
				Assert.IsFalse (d.Focused, "Focus4");

				d.Visible = true;
				d.Focus ();
				Assert.IsTrue (d.Focused, "Focus5");
				Assert.IsFalse (c.Focused, "Focus6");

				c.Enabled = false;
				Assert.IsFalse (c.Focused, "Focus7");
			} finally {
				if (f != null)
					f.Dispose ();
				if (c != null)
					c.Dispose ();
				if (d != null)
					d.Dispose ();
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:40,代码来源:ControlTest.cs

示例8: GetFocusTest

		public void GetFocusTest ()
		{
			using (Form f = new Form ()) {
				f.Show ();

				IRawElementProviderFragmentRoot provider =
					(IRawElementProviderFragmentRoot) ProviderFactory.GetProvider (f);

				Assert.IsNull (provider.GetFocus (),
				               "Nothing is selected and GetFocus is returning something");

				Button b1 = new Button ();
				b1.Location = new System.Drawing.Point (0, 0);
				f.Controls.Add (b1);

				Button b2 = new Button ();
				b2.Location = new System.Drawing.Point (50, 50);
				f.Controls.Add (b2);

				IRawElementProviderSimple button1Provider =
					ProviderFactory.GetProvider (b1);

				b1.Focus ();
				Assert.AreEqual (button1Provider, provider.GetFocus (),
				                 "GetFocus is not returning the first button");

				IRawElementProviderSimple button2Provider =
					ProviderFactory.GetProvider (b2);

				b2.Focus ();
				Assert.AreEqual (button2Provider, provider.GetFocus (),
				                 "GetFocus is not returning the second button");
			}
		}
开发者ID:mono,项目名称:uia2atk,代码行数:34,代码来源:FormProviderTest.cs

示例9: EnterLeaveEvents

		public void EnterLeaveEvents ()
		{
			Form f = new Form ();
			TabControl tc = new TabControl ();
			TabPage p1 = new TabPage ();
			string events = string.Empty;
			tc.Enter += new EventHandler (delegate (Object obj, EventArgs e) { events += ("tc_OnEnter;"); });
			tc.Leave += new EventHandler (delegate (Object obj, EventArgs e) { events += ("tc_OnLeave;"); });
			p1.Enter += new EventHandler (delegate (Object obj, EventArgs e) { events += ("p1_OnEnter;");});
			p1.Leave += new EventHandler (delegate (Object obj, EventArgs e) { events += ("p1_OnLeave;"); });
			tc.TabPages.Add (p1);

			Button b1 = new Button ();

			tc.TabIndex = 0;
			b1.TabIndex = 1;

			f.Controls.Add (b1);
			f.Controls.Add (tc);

			f.Show ();
			Assert.AreEqual ("tc_OnEnter;p1_OnEnter;", events, "A1");
			b1.Focus ();
			Assert.AreEqual ("tc_OnEnter;p1_OnEnter;p1_OnLeave;tc_OnLeave;", events, "A2");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:25,代码来源:TabControlTest.cs

示例10: InitializeComponent

        private void InitializeComponent()
        {
            Text = "Error";

            okButton = new System.Windows.Forms.Button();
            cancelButton = new System.Windows.Forms.Button();
            detailsButton = new System.Windows.Forms.Button();
            pictureBox = new System.Windows.Forms.PictureBox();
            errorLabel = new System.Windows.Forms.Label();
            errorMessageLabel = new System.Windows.Forms.Label();
            SuspendLayout();
            //
            // okButton
            //
            okButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
            okButton.Location = new System.Drawing.Point(160, 100);
            okButton.Name = "okButton";
            okButton.TabIndex = 0;
            okButton.Text = "OK";
            okButton.Click += new EventHandler(okButton_Click);
            AcceptButton = okButton;
            //
            // cancelButton
            //
            cancelButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
            cancelButton.Location = new System.Drawing.Point(240, 100);
            cancelButton.Name = "cancelButton";
            cancelButton.TabIndex = 1;
            cancelButton.Text = "Cancel";
            CancelButton = cancelButton;
            //
            // detailsButton
            //
            detailsButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
            detailsButton.Location = new System.Drawing.Point(320, 100);
            detailsButton.Name = "detailsButton";
            detailsButton.TabIndex = 2;
            detailsButton.Text = "Details";
            detailsButton.Click += new EventHandler(detailsButton_Click);
            //
            // pictureBox
            //
            pictureBox.Location = new System.Drawing.Point(11, 11);
            pictureBox.Name = "pictureBox";
            pictureBox.Size = new System.Drawing.Size(40, 40);
            pictureBox.TabIndex = 3;
            pictureBox.TabStop = false;
            Bitmap errorImage = new Bitmap(WixFiles.GetResourceStream("error.png"));
            errorImage.MakeTransparent();
            pictureBox.Image = errorImage;
            //
            // errorLabel
            //
            errorLabel.Location = new System.Drawing.Point(64, 20);
            errorLabel.Name = "errorLabel";
            errorLabel.Size = new System.Drawing.Size(456, 40);
            errorLabel.TabIndex = 4;
            errorLabel.Text = message;
            //
            // errorLabel
            //
            errorMessageLabel.Location = new System.Drawing.Point(64, 60);
            errorMessageLabel.Name = "errorMessageLabel";
            errorMessageLabel.Size = new System.Drawing.Size(456, 40);
            errorMessageLabel.TabIndex = 4;
            errorMessageLabel.Text = "Error message: " + exception.Message;
            //
            // ExceptionForm
            //
            AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            ClientSize = new System.Drawing.Size(545, 134);
            Controls.Add(errorLabel);
            Controls.Add(errorMessageLabel);
            Controls.Add(pictureBox);
            Controls.Add(detailsButton);
            Controls.Add(cancelButton);
            Controls.Add(okButton);
            FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            MaximizeBox = false;
            MinimizeBox = false;
            Name = "ExceptionForm";
            ShowInTaskbar = false;
            ResumeLayout(false);

            okButton.Focus();

            CenterToScreen();
        }
开发者ID:xwiz,项目名称:WixEdit,代码行数:88,代码来源:ExceptionForm.cs

示例11: EditQbtn

        private void EditQbtn(Button btn)
        {
            btn.Focus();
            Color oriBgColor = btn.BackColor;
            Color oriForeColor = btn.ForeColor;
            btn.BackColor = SystemColors.Highlight;
            btn.ForeColor = SystemColors.HighlightText;

            int i = QbtnIndex(btn);
            frmQEditor UI = QEditorUI;
            UI.Left = this.Right - UI.Width;
            UI.Top = this.Bottom - UI.Height;
            UI.ClearAll();
            UI.ReadFrom(Qs[i - 1]);
            if (UI.ShowDialog() == DialogResult.OK)
            {
                UI.WriteTo(ref Qs[i - 1]);
                Program.SaveSettings();
            }
            RefreshQbtn();

            btn.BackColor = oriBgColor;
            btn.ForeColor = oriForeColor;
            if (!Program.beClassic) btn.UseVisualStyleBackColor = true;
        }
开发者ID:wyrover,项目名称:SuperCMD,代码行数:25,代码来源:frmMain.cs

示例12: ShowExpandedMessageBox

 private static void ShowExpandedMessageBox(string messageString)
 {
     var messageForm = new Form(){Size = new Size(500,300)};
     var splitContainer = new SplitContainer()
                              {
                                  Dock = DockStyle.Fill,
                                  IsSplitterFixed = true,
                                  SplitterWidth = 1,
                                  SplitterDistance = 300,
                                  Orientation = Orientation.Horizontal,
                                  Panel2MinSize = 20
                              };
     splitContainer.Resize +=
         (x, y) => { splitContainer.SplitterDistance = messageForm.Size.Height - 67; };
     var okButton = new Button
                        {
                            DialogResult = DialogResult.OK,
                            Text = "Ok",
                            Anchor = (AnchorStyles.Right | AnchorStyles.Top),
                            //Location = new System.Drawing.Point(414, 4),
                            Size = new Size(75,23),
                            Dock = DockStyle.Right
                        };
     splitContainer.Panel2.Controls.Add(okButton);
     var textBox = new TextBox
                       {
                           Multiline = true,
                           ScrollBars = ScrollBars.Both,
                           Dock = DockStyle.Fill,
                           Text = messageString.Trim(),
                           ReadOnly = true,
                           SelectionLength = 0,
                           TabStop = false
                       };
     splitContainer.Panel1.Controls.Add(textBox);
     messageForm.Controls.Add(splitContainer);
     messageForm.ShowDialog();
     okButton.Focus();
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:39,代码来源:IDPickerForm.cs

示例13: GotFocusSelectedIndex

		public void GotFocusSelectedIndex ()
		{
			TabControl tc = new TabControl ();
			tc.TabPages.Add ("A");
			tc.TabPages.Add ("B");

			Button b = new Button (); // Dummy button to receive focus by default
			Form f = new Form ();
			f.Controls.AddRange (new Control [] { b, tc });
			f.Show ();

			tc.SelectedIndex = -1;

			// Make sure focus goes back to button
			b.Focus ();

			// Finally give focus back to TabControl
			tc.Focus ();

			Assert.AreEqual (-1, tc.SelectedIndex, "#A0");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:21,代码来源:TabControlTest.cs

示例14: SelectedIndexChangeFiresFocus

		[Test] // bug #499887
		public void SelectedIndexChangeFiresFocus ()
		{
			Form f = new Form ();
			TabControl tc = new TabControl ();
			TabPage p1 = new TabPage ();
			TabPage p2 = new TabPage ();
			string events = string.Empty;

			tc.TabPages.Add (p1);
			tc.TabPages.Add (p2);
			tc.SelectedIndex = 0;
			Button b1 = new Button ();
			Button b2 = new Button ();

			f.Controls.Add (b1);
			f.Controls.Add (b2);
			f.Controls.Add (tc);

			f.Show ();
			b1.Focus ();
			b2.GotFocus += new EventHandler (delegate (Object obj, EventArgs e) {
				tc.SelectedIndex = 1;
			});
			
			tc.GotFocus += new EventHandler(delegate (Object obj, EventArgs e) { events += ("tc_OnGotFocus" + tc.SelectedIndex + ";"); });
			tc.SelectedIndexChanged += new EventHandler(delegate (Object obj, EventArgs e) { events += ("tc_OnSelectedIndexChanged" + tc.SelectedIndex + ";"); });
			p2.Enter += new EventHandler(delegate (Object obj, EventArgs e) { events += ("p2_OnEnter" + tc.SelectedIndex + ";"); });
			p2.Leave += new EventHandler (delegate (Object obj, EventArgs e) { events += ("p2_OnLeave;"); });
	
			b2.Focus ();
			Assert.AreEqual ("tc_OnGotFocus0;p2_OnEnter1;tc_OnSelectedIndexChanged1;", events, "A1");
			Assert.IsTrue (tc.Focused, "A2");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:34,代码来源:TabControlTest.cs

示例15: MovePanelWest

        // Shift Panel to the West.
        public void MovePanelWest()
        {
            // Set new Coordinates.
            iCurrentX -= 1;

            // Clear Map Rooms.
            ClearRooms();

            // Get New Room Control.
            Button room = new Button();
            string strRoomName = "room" + iCurrentRoom;
            Control[] btnRoom = this.Controls.Find(strRoomName, true);
            if (btnRoom != null)
            {
                room = (Button)btnRoom[0];
                room.Focus();
            }

            // Current Room Details.
            SetCurrentRoom();

            // Update the Room Zoom View for the current room.
            UpdateZoomView(room);

            // Display the Current Map.
            DisplayPanelRooms(iCurrentArea, iCurrentX, iCurrentY, iCurrentZ);
        }
开发者ID:kerchunk,项目名称:GizMaker,代码行数:28,代码来源:Mapper.cs


注:本文中的System.Windows.Forms.Button.Focus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。