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


C# ComboBox.Focus方法代码示例

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


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

示例1: CheckComboBox

        /// <summary>
        /// 檢查組合框是否已經選擇
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public static bool CheckComboBox(ComboBox target)
        {
            if (target.SelectedItem == null)
            {
                target.Focus();
                return false;
            }

            if (target.Text == "")
            {
                target.Focus();
                return false;
            }

            return true;
        }
开发者ID:Klutzdon,项目名称:SIOTS_HHZX,代码行数:21,代码来源:CommonFunction.cs

示例2: IsValidComboBox

 /// <summary>
 /// Indicates whether the Specified single Combobox is not Empty/Null.
 /// </summary>
 /// <param name="combobox">Combobox</param>
 /// <returns>
 /// Boolean Value
 /// </returns>
 public static bool IsValidComboBox(ComboBox combobox)
 {
     if (combobox.SelectedIndex == -1)
     {
         combobox.Focus();
         return false;
     }
     return true;
 }
开发者ID:QasimAshraf18,项目名称:ControlValidation,代码行数:16,代码来源:Validation.cs

示例3: ComboContainsData

 //method to check for blank combobox entry
 public static bool ComboContainsData(ComboBox comboBox, string name)
 {
     if (comboBox.Text == "")
     {
         MessageBox.Show(name + " cannot be blank. Please make a selection from the combo box and resubmit.", Title);
         comboBox.Focus();
         return false;
     }
     return true;
 }
开发者ID:houckster,项目名称:Expense-Summary-App,代码行数:11,代码来源:Validation.cs

示例4: IsSelected

 public static bool IsSelected(ComboBox combo)
 {
     if (combo.Text == "")
     {
         MessageBox.Show(combo.Tag + " is a required field.", Title);
         combo.Focus();
         return false;
     }
     return true;
 }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:10,代码来源:Validator.cs

示例5: IsSelected

 public bool IsSelected(ComboBox comboBox)
 {
     if (Convert.ToInt32(comboBox.SelectedIndex) == -1)
     {
         MessageBox.Show("Du måste välja ett värde i listan!");
         comboBox.Focus();
         return false;
     }
     return true;
 }
开发者ID:Zaitzewsky,项目名称:Informatik-B--Objektorienterad-programmering-med-C-,代码行数:10,代码来源:ValideringInData.cs

示例6: checkSendAsEmail

 //Check sendAs email is selected
 public bool checkSendAsEmail(ComboBox ddList)
 {
     int emailIndex = ddSendAs.SelectedIndex;
     if (emailIndex == 0)
     {
         MessageBox.Show("Please check a valid 'Send As' Email Address", "Confirm 'Send As' Email");
         ddList.Focus();
         return false;
     }
     else
     {
         return true;
     }
 }
开发者ID:angeles890,项目名称:localApps,代码行数:15,代码来源:Form1.cs

示例7: ComboEmpty

 internal static bool ComboEmpty(ComboBox combo, object strip = null, int Index = 0)
 {
     bool result = false;
     if (combo.SelectedIndex == -1)
     {
         result = true;
         MessageBox.Show("Please select an option from the list", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         //UPGRADE_WARNING: (2080) IsEmpty was upgraded to a comparison and has a new behavior. More Information: http://www.vbtonet.com/ewis/ewi2080.aspx
         if (!Index.Equals(0))
         {
             //strip.SelectedItem = strip.Tabs(Index)
         }
         combo.Focus();
     }
     else
     {
         result = false;
     }
     return result;
 }
开发者ID:WebMAPTestUser,项目名称:SKS,代码行数:20,代码来源:modFunctions.cs

示例8: IsValidateComboBoxSuccess

 public static bool IsValidateComboBoxSuccess(ComboBox comboBox, string messageString)
 {
     if (string.IsNullOrEmpty(comboBox.Text.Trim()))
     {
         comboBox.Focus();
         MessageBox.Show(messageString);
         comboBox.Focus();
         return false;
     }
     else
     {
         return true;
     }
 }
开发者ID:BAICA,项目名称:Multi-Laptop-Manager,代码行数:14,代码来源:Security.cs

示例9: ShowCombobox

        /// <summary>
        /// 
        /// </summary>
        /// <param name="lv"></param>
        /// <param name="lst"></param>
        /// <param name="x">鼠标的x坐标</param>
        /// <param name="y">鼠标的y坐标</param>
        /// <param name="col">ComboBox显示在哪个列上</param>
        /// <param name="defaultValueCol">ComboBox的默认值列</param>
        private static void ShowCombobox(ListView lv, ComboBox lst, int x, int y, int col, int defaultValueCol)
        {
            var item = lv.GetItemAt(x, y);
            if (item == null || !item.Checked)
                return;
            comboboxItem = item;

            int lWidth = 0, rWidth = 0;
            for (int i = 0; i <= col; i++)
            {
                int tmp = lv.Columns[i].Width;
                if (i < col)
                    lWidth += tmp;
                rWidth += tmp;
            }

            if (x > rWidth || x < lWidth)
            {
                lst.Visible = false;
                return;
            }

            //获取所在位置的行的Bounds            
            Rectangle rect = item.Bounds;
            //修改Rect的范围使其与第二列的单元格的大小相同,为了好看 ,左边缩进了2个单位                       
            rect.X += lv.Left + lWidth + 2;
            rect.Y += lv.Top + 2;
            rect.Width = rWidth - lWidth;
            lst.Bounds = rect;
            string val = item.SubItems[col].Text;
            if (string.IsNullOrEmpty(val) && defaultValueCol >= 0 && item.SubItems.Count > defaultValueCol)
                val = item.SubItems[defaultValueCol].Text;
            lst.Text = val;
            lst.Visible = true;
            lst.BringToFront();
            lst.Focus();
            lst.Name = col.ToString();

            //lst.SelectedIndexChanged -= lstSelectedIndexChanged;// (obj, args) => { MessageBox.Show("1"); };
        }
开发者ID:bincle,项目名称:Beinet.cn.Tools,代码行数:49,代码来源:MainForm.cs

示例10: ChooseLanguage

        /// <summary>
        /// Shows a form for choosing the language file from all other files.
        /// </summary>
        /// <returns>the DialogResult of this Form</returns>
        public static Form.DialogResult ChooseLanguage()
        {
            Directory.CreateDirectory(Program.ExePath + @"\temp");
            Languages.Zip.ExtractAll(Program.ExePath + @"\Languages.dll", Program.ExePath + @"\temp");

            Form.Form form = new Form.Form();

            Form.ComboBox list_languages = new Form.ComboBox();
            Form.Label lb_text = new System.Windows.Forms.Label();
            Form.Button bt_add = new System.Windows.Forms.Button();
            Form.Button bt_ok = new System.Windows.Forms.Button();

            list_languages.Location = new System.Drawing.Point(16, 48);
            list_languages.Size = new System.Drawing.Size(266, 21);
            list_languages.TabIndex = 0;
            {
                string[] files = Directory.GetFiles(Program.ExePath + @"\temp");
                if (files.Length > 0)
                    list_languages.Text = Path.GetFileNameWithoutExtension(files[0]);
                System.Array.Sort(files);
                foreach (string a in files)
                    if (!list_languages.Items.Contains(new Form.ListViewItem(Path.GetFileNameWithoutExtension(a))))
                        list_languages.Items.Add(Path.GetFileNameWithoutExtension(a));
            }

            lb_text.AutoSize = true;
            lb_text.Location = new System.Drawing.Point(13, 13);
            lb_text.Size = new System.Drawing.Size(92, 13);
            lb_text.TabIndex = 1;
            lb_text.Text = "choose language:";
            bt_add.Location = new System.Drawing.Point(169, 94);
            bt_add.Size = new System.Drawing.Size(113, 23);
            bt_add.TabIndex = 2;
            bt_add.Text = "Add Language to list";
            bt_add.UseVisualStyleBackColor = true;
            bt_add.Click += delegate
            {
                string path = Program.SelectFile("XML files (*.xml)|*.xml|All files (*.*)|*.*","Open");
                if (path != null)
                {
                    string textInZip = Languages.Convertor.getLanguageText(path);
                    Languages.Convertor.ConvertToLanguageFile(path, Program.ExePath + @"\" + textInZip + ".xml");
                    Languages.Zip.AddFile(Program.ExePath + @"\" + textInZip + ".xml", textInZip + ".xml");
                    if (!list_languages.Items.Contains(Path.GetFileNameWithoutExtension(textInZip)))
                        list_languages.Items.Add(Path.GetFileNameWithoutExtension(textInZip));
                    Languages.Convertor.ChosenLanguage_FilePath = Program.ExePath + @"\temp\" + textInZip + ".xml";
                    list_languages.SelectedIndex = 0;
                    File.Delete(Program.ExePath + @"\" + textInZip + ".xml");
                }
            };

            bt_ok.Location = new System.Drawing.Point(80, 142);
            bt_ok.Size = new System.Drawing.Size(109, 35);
            bt_ok.TabIndex = 3;
            bt_ok.Text = "OK";
            bt_ok.UseVisualStyleBackColor = true;
            bt_ok.Click += delegate
            {
                form.DialogResult = Form.DialogResult.OK;
                properties.chosenLanguage = list_languages.Text;
                form.Close();
            };

            form.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            form.AutoScaleMode = Form.AutoScaleMode.Font;
            form.ClientSize = new System.Drawing.Size(303, 255);
            form.MinimumSize = new System.Drawing.Size(303, 255);
            form.MaximumSize = new System.Drawing.Size(303, 255);
            form.MaximizeBox = false;
            form.MinimizeBox = false;
            form.Controls.AddRange(new Form.Control[] { list_languages, lb_text, bt_add, bt_ok });
            form.Icon = new System.Drawing.Icon(Peulot_Heshbon.Properties.Resources.App_Icon, new System.Drawing.Size(32, 32));
            form.Text = "Choose Language";
            form.ResumeLayout(false);
            form.PerformLayout();
            form.DialogResult = Form.DialogResult.Cancel;

            list_languages.Focus();

            Form.DialogResult dg = form.ShowDialog();
            Directory.Delete(Program.ExePath + @"\temp", true);

            return dg;
        }
开发者ID:arthurzam,项目名称:peulot-heshbon,代码行数:88,代码来源:Start.cs

示例11: LoadAlmCustomFieldSuccessful

 private void LoadAlmCustomFieldSuccessful(List<string> AlmCustomFieldsList, ComboBox AlmCustomField, string CustomFieldLabel)
 {
     AlmProjectGroup.Invoke(new MethodInvoker(delegate
     {
         AlmCustomField.Items.Clear();
         if (AlmCustomFieldsList.Count > 0)
         {
             AlmCustomField.Items.AddRange(AlmCustomFieldsList.ToArray());
             AlmCustomField.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
         }
         LogMessage("Finished loading " + CustomFieldLabel + "s.");
         AlmCustomField.Enabled = true;
         AlmCustomField.Focus();
     }));
 }
开发者ID:hpalmtools,项目名称:go2ALM,代码行数:15,代码来源:Go2ALMView_AlmProjectTab_CustomFields.cs

示例12: userChoice

		public userChoice( string title, string text, string[] choices, int Default, string ok, string cancel )
		{
			platformSpec.manageWindows.setUserInputSize( this );
			platformSpec.setFloatingWindow.before( this );
		//	this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 
			this.ControlBox = false; 

			int space = 8;
			this.Text = title; 
		//	this.Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width * 3 / 4; 

			Label lbl = new Label();
			lbl.Text = text;
			lbl.Top = space;
			lbl.Left = space;
			lbl.Width = this.Width - 2 * space;

			System.Drawing.Bitmap bmp = new System.Drawing.Bitmap( 1, 1 );
			System.Drawing.Graphics g = System.Drawing.Graphics.FromImage( bmp );
			string[] words = text.Split( " ".ToCharArray() );
			int lines = 1, lineWidth = 0;
			for ( int i = 0; i < words.Length; i++ )
			{
				lineWidth += (int)g.MeasureString( words[ i ] + ( i < words.Length - 1? " " : "" ), lbl.Font ).Width;
				if ( lineWidth >= lbl.Width )
				{
					lines++;
					lineWidth = 0;
					i--;
				}
			}

			lbl.Height = lines * (int)g.MeasureString( words[0 ] + " ", lbl.Font ).Height;

			g.MeasureString( text, lbl.Font );

			cb = new ComboBox();

			cb.Left = space;
			cb.Top = lbl.Bottom + space;
			cb.Width = this.ClientSize.Width - 2 * space;
			for ( int i = 0; i < choices.Length; i++ )
				cb.Items.Add( choices[ i ] );

			cb.SelectedIndex = Default;

			Button cmdOk = new Button();
			cmdOk.Width = ( this.ClientSize.Width - 3 * space ) / 2;
			cmdOk.Left = space;
			cmdOk.Top = cb.Bottom + space;
			cmdOk.Text = ok; //language.getAString();//language.order.ok );//ok;
			cmdOk.Click += new EventHandler(cmdOk_Click);
#if !CF
			cmdOk.FlatStyle = FlatStyle.System;
#endif
			
			Button cmdCancel = new Button();
			cmdCancel.Width = ( this.ClientSize.Width - 3 * space ) / 2;
			cmdCancel.Left = space + cmdOk.Right;
			cmdCancel.Top = cb.Bottom + space;
			cmdCancel.Text = cancel; //language.getAString(); //language.order.cancel );//cancel;
			cmdCancel.Click += new EventHandler(cmdCancel_Click);
#if !CF
			cmdCancel.FlatStyle = FlatStyle.System;
#endif

			this.Controls.Add( lbl );
			this.Controls.Add( cmdOk );
			this.Controls.Add( cmdCancel );
			this.Controls.Add( cb );

			platformSpec.resolution.set( this.Controls );

			this.ClientSize = new Size( this.ClientSize.Width, space * 4 + lbl.Height + cb.Height + cmdOk.Height ); // this.Height = space * 4 + lbl.Height + cb.Height + cmdOk.Height;

			platformSpec.setFloatingWindow.after( this );
			
			this.ClientSize = new Size( this.ClientSize.Width, space + cmdOk.Bottom ); //.Height = space * 4 + lbl.Height + tb.Height + cmdOk.Height;

			this.Top = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height / 2 - this.Height / 2;
			this.Left = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 2 - this.Width / 2;

			cb.Focus();
		}
开发者ID:jithuin,项目名称:infogeezer,代码行数:84,代码来源:userChoice.cs

示例13: DeptSelectChanged

        private void DeptSelectChanged(ComboBox dept, ComboBox emp)
        {
            //��ȡ��Ա�б�
            emp.Text = "";
            emp.Items.Clear();
            string sSql = "select emp_nam from emp where dept_nam = \'" + dept.Text + "\'";
            MySqlDataReader reader = MysqlHelper.ExecuteReader(sSql);
            while (reader.Read())
            {
                emp.Items.Add(reader["emp_nam"].ToString());
            }

            if (emp.Items.Count == 1)
            {
                emp.SelectedIndex = 0;
            }
            else
            {
                emp.Focus();
                emp.DroppedDown = true;
            }
        }
开发者ID:chutinhha,项目名称:asset-management-system,代码行数:22,代码来源:AssSupplyBak.cs

示例14: isSelected

        //presence validation for if a combo box is selected
        public bool isSelected(ComboBox combobox, string name)
        {
            if (combobox.SelectedIndex < 0)
            {
                MessageBox.Show(name + " must be selected", "Error");
                combobox.Refresh();
                combobox.Focus();
                return false;
            }

            return true;
        }
开发者ID:jlarson497,项目名称:InventoryManagement,代码行数:13,代码来源:Form1.cs

示例15: SubCheckInput

        /// <summary>
        /// 检查表达式
        /// </summary>
        /// <param name="cmbLeftBrackets">左括号</param>
        /// <param name="cmbColumn">列</param>
        /// <param name="cmbCondition">条件</param>
        /// <param name="txtValue">值</param>
        /// <param name="cmbValue">选项值</param>
        /// <param name="cmbRightBrackets">右括号</param>
        /// <returns>正确</returns>
        private bool SubCheckInput(ComboBox cmbLeftBrackets, ComboBox cmbColumn, ComboBox cmbCondition, TextBox txtValue, ComboBox cmbValue, ComboBox cmbRightBrackets)
        {
            bool returnValue = true;
            if (cmbColumn.SelectedIndex > 0)
            {
                if (cmbCondition.SelectedItem == null)
                {
                    MessageBox.Show(AppMessage.MSG9919, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmbCondition.Focus();
                    returnValue = false;
                }
                if (cmbValue.Visible)
                {
                    if (cmbValue.SelectedItem == null)
                    {
                        MessageBox.Show(AppMessage.MSG9920, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        cmbValue.Focus();
                        returnValue = false;
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(txtValue.Text))
                    {
                        MessageBox.Show(AppMessage.MSG9920, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtValue.Focus();
                        returnValue = false;
                    }
                }
            }

            return returnValue;
        }
开发者ID:huoxudong125,项目名称:DotNet,代码行数:43,代码来源:FrmTableScopeConstraint.cs


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