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


C# ErrorProvider.SetError方法代码示例

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


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

示例1: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            ErrorProvider erro = new ErrorProvider();
            if(TitulotextBox.Text.Length == 0 || DescripcionrichTextBox.Text.Length == 0)
            {
                erro.SetError(TitulotextBox,"No puede dejar este campo vacio");
                erro.SetError(DescripcionrichTextBox,"Debe llenar este campo");
            }
            else
            {
                Pelicula p = new Pelicula();
                p.Titulo = TitulotextBox.Text;
                p.Descripcion = DescripcionrichTextBox.Text;

                int resultado = PeliculaConexion.Agregar(p);

                if(resultado > 0)
                {
                    MessageBox.Show("Se guardo la Pelicula", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    TitulotextBox.Text = "";
                    DescripcionrichTextBox.Text = "";
                }
                else
                {
                    MessageBox.Show("No se pudo guardar la pelicula", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

            }
        }
开发者ID:Melvin0496,项目名称:Tarea-11---Aplicada-I---Melvin-Gabriel-,代码行数:29,代码来源:NuevaPelicula.cs

示例2: btnSave_Click

        private void btnSave_Click(object sender, EventArgs e)
        {
            ErrorProvider errorProvider1 = new ErrorProvider();
            if (string.IsNullOrWhiteSpace(this.txtSubject.Text))
            {
                errorProvider1.SetError(this.txtSubject, "必填。");
                return;
            }
            else
                errorProvider1.SetError(this.txtSubject, "");

            try
            {
                this.btnSave.Enabled = false;
                conf.Content = webBrowser1.Document.Body.InnerHtml.Replace("<div id=\"editable\">", string.Empty);
                conf_subject.Content = this.txtSubject.Text.Trim();
                List<ActiveRecord> recs = new List<ActiveRecord>();
                recs.Add(conf);
                recs.Add(conf_subject);
                (new AccessHelper()).UpdateValues(recs);
                MessageBox.Show("儲存成功。");
                //this.Close();
            }
            catch (Exception ex)
            {
                MsgBox.Show(ex.Message);
            }
            finally
            {
                this.btnSave.Enabled = true;
            }
        }
开发者ID:jungfengpaulwang,项目名称:EMBATeachingEvaluation,代码行数:32,代码来源:CS_Template.cs

示例3: Scalevalue_ok_Click

        private void Scalevalue_ok_Click(object sender, EventArgs e)
        {
            //put validation here
            panel1.Invalidate();
            panel1.Update();
            ErrorProvider error = new ErrorProvider();
            error_Label.Text = "...";
            if (real_length1.Text == "")
            {
                error.SetError(real_length2, "Scale Value cannot be empty");
                error_Label.Text = "Scale Value cannot be empty";
                return;
            }
            else
            {
                error.SetError(real_length2, "");
            }
            if (Convert.ToInt32(real_length1.Text) == 0)
            {
                error.SetError(real_length2, "Enter Proper Scale Value(Scale Value cannot be null or Zero)");
                error_Label.Text = "Scale Value cannot be Zero";
                return;
            }
            else
            {
                error.SetError(real_length2, "");
            }
            if (unit_combobox.SelectedIndex == 0)
            {
                error.SetError(unit_combobox, "Select the unit");
                error_Label.Text = "Select the unit (cm,metre,feet)";
                return;
            }
            else
            {
                error.SetError(unit_combobox, "");
            }
            double scale_calculated = Convert.ToInt32(real_length1.Text.ToString())/pixelvalue;

            ImagePropertiesClass.scale_value = (float)Math.Round(scale_calculated,2);
            ImagePropertiesClass.scale_set = true;//now the scale is set for the loaded image
            ImagePropertiesClass.scale_unit = this.unit_combobox.SelectedItem.ToString();//returns the selected index(unit)
            Console.WriteLine("Value of the Scale is:" + ImagePropertiesClass.scale_value);

            //enter value in db
            Commonforallfunctions.set_scalepoints();
            ProjectClass.db_cmd.CommandText = "UPDATE images set [email protected] ,[email protected]_x1,[email protected]_y1,[email protected]_x2,[email protected]_y2 ,[email protected]_unit where iid=" + ImagePropertiesClass.ImageId + ";";
            ProjectClass.db_cmd.Parameters.AddWithValue("@scale", ImagePropertiesClass.scale_value);
            ProjectClass.db_cmd.Parameters.AddWithValue("@scale_x1",ImagePropertiesClass.scale_startpt.X );
            ProjectClass.db_cmd.Parameters.AddWithValue("@scale_y1", ImagePropertiesClass.scale_startpt.Y);
            ProjectClass.db_cmd.Parameters.AddWithValue("@scale_x2", ImagePropertiesClass.scale_endpt.X);
            ProjectClass.db_cmd.Parameters.AddWithValue("@scale_y2", ImagePropertiesClass.scale_endpt.Y);
            ProjectClass.db_cmd.Parameters.AddWithValue("@scale_unit",ImagePropertiesClass.scale_unit);
            ProjectClass.db_cmd.ExecuteNonQuery();

            this.Dispose();
        }
开发者ID:ssntpl,项目名称:MeasureIt,代码行数:57,代码来源:ScaleDetails.cs

示例4: Import_Click

        private void Import_Click(object sender, EventArgs e)
        {
            bool OK = true;
            ErrorProvider errorProvider = new ErrorProvider();

            if (string.IsNullOrWhiteSpace(Survey.Text))
            {
                errorProvider.SetError(this.Survey, "必填。");
                OK = false;
            }
            else
                errorProvider.SetError(this.Survey, "");

            if (this.Template == null && string.IsNullOrWhiteSpace(FileName.Text))
            {
                errorProvider.SetError(this.FileName, "請選擇樣版檔。");
                OK = false;
            }
            else
            {
                errorProvider.SetError(this.FileName, "");
            }

            if (!OK)
                return;

            try
            {
                string base64string = string.Empty;

                if (!string.IsNullOrEmpty(this.FileName.Text))
                    base64string = TransferFileToBase64String(this.FileName.Text);

                int SurveyID = int.Parse((this.Survey.Items[this.Survey.SelectedIndex] as ComboItem).Tag + "");

                if (this.WriteTemplate(base64string, SurveyID))
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    MessageBox.Show("儲存成功。");
                    this.Close();
                    return;
                }
                else
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.None;
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.DialogResult = System.Windows.Forms.DialogResult.None;
                return;
            }
        }
开发者ID:jungfengpaulwang,项目名称:EMBATeachingEvaluation,代码行数:55,代码来源:ImportReportDocumentTemplate.cs

示例5: ValidateRequiredField

        public static bool ValidateRequiredField(ErrorProvider errorProvider, Control control)
        {
            if (string.IsNullOrEmpty(control.Text))
            {
                errorProvider.SetError(control, "A mező kötelező");
                return false;
            }

            errorProvider.SetError(control, null);
            return true;
        }
开发者ID:imrekoszo,项目名称:munkanaplo,代码行数:11,代码来源:FormHelpers.cs

示例6: ComboBoxValideNonVide

 public static void ComboBoxValideNonVide(object sender, ErrorProvider errProvider, String errMessage, CancelEventArgs e)
 {
     var combobox = (ComboBox)sender;
     if (combobox.SelectedIndex < 0)
     {
         errProvider.SetError(combobox, errMessage);
         e.Cancel = true;
     }
     else
     {
         errProvider.SetError(combobox, "");
     }
 }
开发者ID:KelvinEstMexicain,项目名称:Projet3,代码行数:13,代码来源:Validation.cs

示例7: validarDatos

 private void validarDatos(ErrorProvider ep, TextBox txt)
 {
     if (txt.Text.Trim().Length == 0)
     {
         ep.Icon = Icon.FromHandle(((Bitmap)imageList1.Images[0]).GetHicon());
         ep.SetError(txt, "Dato no válido");
     }
     else
     {
         ep.Icon = Icon.FromHandle(((Bitmap)imageList1.Images[1]).GetHicon());
         ep.SetError(txt, "Dato Correcto");
     }
 }
开发者ID:elein01,项目名称:Aplicaciones,代码行数:13,代码来源:AddAdministrativo.cs

示例8: ValidationHelper

 /// <summary>
 /// Most forms use errorprovider for validation, this method is a utility method that will
 /// control the toggling of the errorprovider, and it returns a 1 if there was an error,
 /// and 0 if there wasn't.  This is most often used with a int errorCount = 0; statement so
 /// the validation can determine if there were errors easily.
 /// </summary>
 /// <param name="test"></param>
 /// <param name="provider"></param>
 /// <param name="control"></param>
 /// <param name="msg"></param>
 /// <returns></returns>
 public static int ValidationHelper(bool test, ErrorProvider provider, Control control, string msg)
 {
     if (test)
     {
         provider.SetError(control, msg);
         return 1;
     }
     else
     {
         provider.SetError(control, "");
         return 0;
     }
 }
开发者ID:antmason,项目名称:libelluspersonallibrary,代码行数:24,代码来源:UIUtils.cs

示例9: PeopleForm

 public PeopleForm(string title=null, IPeopleFormDelegate peopleFormDelegate = null, bool openForUpdate = false,string surname="", string firstname="", string password="", string comment="")
 {
     if (null != title) this.Text = title;
     _openForUpdate = openForUpdate;
     _peopleFormDelegate = peopleFormDelegate;
     this.SetBounds(10, 10, 200, 220);
     Label lbl1, lbl2,lbl3, lbl4;
     TextBox txt1, txt2,txt3,txt4;
     Button btn = new Button();
     this.Controls.Add(lbl1 = new Label());
     lbl1.SetBounds(5, 5, 185, 18);
     lbl1.Text = "firstname";
     this.Controls.Add(txt1 = new TextBox());
     txt1.SetBounds(5, 25, 185, 18);
     txt1.Text = firstname;
     this.Controls.Add(lbl2 = new Label());
     lbl2.Text = "surname";
     lbl2.SetBounds(5, 45, 185, 18);
     this.Controls.Add(txt2 = new TextBox());
     txt2.SetBounds(5, 65, 165, 18);
     txt2.Text = surname;
     this.Controls.Add(lbl3 = new Label());
     lbl3.SetBounds(5, 85, 185, 18);
     lbl3.Text = "password";
     this.Controls.Add(txt3 = new TextBox());
     txt3.SetBounds(5, 105, 185, 18);
     txt3.Text = password;
     this.Controls.Add(lbl4 = new Label());
     lbl4.SetBounds(5, 125, 185, 18);
     lbl4.Text = "comment";
     this.Controls.Add(txt4 = new TextBox());
     txt4.SetBounds(5, 145, 185, 18);
     txt4.Text = comment;
     this.Controls.Add(btn);
     btn.SetBounds(5, 165, 185, 18);
     ErrorProvider ep = new ErrorProvider();
     ep.SetIconAlignment(txt2, ErrorIconAlignment.MiddleRight);
     ep.SetIconPadding(txt2, 2);
     btn.Text = openForUpdate ? "Save people" : "Add people";
     btn.Click += (object sender1, EventArgs e1) =>
     {
         if (string.IsNullOrWhiteSpace(txt2.Text))
         {
             ep.SetError(txt2, "Surname must contain chars");
             return;
         }
         ep.SetError(txt2, string.Empty);
         if (null != this._peopleFormDelegate) _peopleFormDelegate.saved(txt2.Text, txt1.Text, txt3.Text, txt4.Text);
         if(openForUpdate) this.Close();
     };
 }
开发者ID:NivekAlunya,项目名称:csharp,代码行数:51,代码来源:FormPeople.cs

示例10: ValidateConfirmField

        public static bool ValidateConfirmField(ErrorProvider errorProvider, Control confirmField, Control referenceField)
        {
            if (!string.IsNullOrEmpty(confirmField.Text))
            {
                if (referenceField.Text != confirmField.Text)
                {
                    errorProvider.SetError(confirmField, "A két mező tartalma különbözik");
                    return false;
                }

                errorProvider.SetError(confirmField, null);
            }
            return true;
        }
开发者ID:imrekoszo,项目名称:munkanaplo,代码行数:14,代码来源:FormHelpers.cs

示例11: LineName_ok_Click

        private void LineName_ok_Click(object sender, EventArgs e)
        {
            ErrorProvider error = null;
            if (this.LineName.Text == "")
            {
                error = new ErrorProvider();
                error.SetError(this.LineName, "Enter line name");
                error_Label.Text = "Enter line name";
            }

            SQLiteDataReader db_data_lines;
            SQLiteCommand db_cmd_lines = ProjectClass.db_con.CreateCommand(); ;
            db_cmd_lines.CommandText = "SELECT name FROM lines ;";
            db_data_lines = db_cmd_lines.ExecuteReader();
            while (db_data_lines.Read())
                if (this.LineName.Text == db_data_lines.GetString(0))
                {
                    error = new ErrorProvider();
                    error.SetError(this.LineName, "line name exists");
                    error_Label.Text = "line name exists";
                    return;
                }

            {
                linename = this.LineName.Text;
                this.DialogResult = DialogResult.OK;

            }
        }
开发者ID:ssntpl,项目名称:MeasureIt,代码行数:29,代码来源:LineDetails.cs

示例12: ValidateCheckList

 public static bool ValidateCheckList(CheckedListBox boxes, ErrorProvider errorProvider)
 {
     if(boxes.CheckedItems.Count > 0)
         return true;
     errorProvider.SetError(boxes, "Este campo es obligatorio");
     return false;
 }
开发者ID:faloi,项目名称:cuponete,代码行数:7,代码来源:ValidatorHelper.cs

示例13: formValido

        public bool formValido(ErrorProvider errorProvider)
        {
            bool validado = true;

            foreach (var objeto in objetosValidar)
            {
                switch (objeto.Tipo)
                {
                    case TipoCampos.Texto:
                        if (((TextBox)objeto.Objeto).Text == string.Empty)
                        {
                            errorProvider.SetError((Control)objeto.Objeto, objeto.Mensaje == string.Empty ? "Debe ingresar el valor solicidado" : objeto.Mensaje);
                            validado = false;
                        }

                        break;
                    case TipoCampos.Numero:
                        break;
                    default:
                        break;
                }
            }

            return validado;
        }
开发者ID:ehitel,项目名称:PERFECT-DS,代码行数:25,代码来源:ValidacionCampos.cs

示例14: ValidateComboBox

 public static bool ValidateComboBox(ComboBox boxes, ErrorProvider errorProvider)
 {
     if (!boxes.SelectedIndex.Equals(-1))
         return true;
     errorProvider.SetError(boxes, "Este campo es obligatorio");
     return false;
 }
开发者ID:faloi,项目名称:cuponete,代码行数:7,代码来源:ValidatorHelper.cs

示例15: TextBox_ValidatingPort

        public static void TextBox_ValidatingPort(CancelEventArgs e, TextBox textBox, ErrorProvider errorProvider)
        {
            string errorMsg;
            if (StringNotEmpty(textBox.Text, out errorMsg) && ValidPort(textBox.Text, out errorMsg)) return;
            e.Cancel = true;

            errorProvider.SetError(textBox, errorMsg);
        }
开发者ID:abezzubets,项目名称:DDTGenerator,代码行数:8,代码来源:Validator.cs


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