Re: Issues with Control focus and error provider location

Carlos Alberto Cortez <[email protected]>
Newsgroups gmane.comp.gnome.winforms
Message-ID <[email protected]>
We have implemented this feature, but it's only available in the trunk
version, and will be available in the next 2.6 release as well.

Carlos.

2009/6/9 Jijesh <[email protected]>

>
> Hi Friends,
>
> I have a dataentry application developed in C# winforms. In that, most of
> the testbox fields are validated using conditions and error providers. When
> i tried the application in ubuntu using mono, the validations are not
> working. In actual situation the focus should not go from the control if
> the
> validation fails. but the focus goes off in this scenario.
>
> Please look into the sample code i wrote for this scenario to test. Here i
> have two text boxes in a group box and one error provider. The textbox
> entry
> is validating on the "textBox1_Validating" event handler.
>
> public partial class Form1 : Form
>    {
>        private System.Windows.Forms.TextBox textBox1;
>        private System.Windows.Forms.Button button1;
>        private System.Windows.Forms.ErrorProvider errorProvider1;
>        private System.Windows.Forms.GroupBox groupBox1;
>        private System.Windows.Forms.TextBox textBox2;
>
>        public Form1()
>        {
>            InitializeComponent();
>        }
>
>        private void textBox1_Validating(object sender, CancelEventArgs e)
>        {
>            if (textBox1.Text != "")
>            {
>                try
>                {
>                    DateTime validatedate =
> Convert.ToDateTime(textBox1.Text.Trim());
>                    if (validatedate.Year < 1900)
>                    {
>
>                        MessageBox.Show("Enter a valid Date");
>                        textBox1.Focus();
>                        return;
>                    }
>                    else
>                        errorProvider1.SetError(textBox1, "");
>                }
>                catch
>                {
>
>                    errorProvider1.SetError(textBox1, "Enter a valid Date");
>                    textBox1.Focus();
>                }
>            }
>            else
>                errorProvider1.SetError(textBox1, "");
>        }
>
>        private void textBox2_Validating(object sender, CancelEventArgs e)
>        {
>            if (textBox2.Text != "")
>            {
>                try
>                {
>                    DateTime validatedate =
> Convert.ToDateTime(textBox2.Text.Trim());
>                    if (validatedate.Year < 1900)
>                    {
>
>                        errorProvider1.SetError(textBox2, "Enter a valid
> Date2");
>
>                        textBox2.Focus();
>                        return;
>                    }
>                    else
>                        errorProvider1.SetError(textBox2, "");
>                }
>                catch
>                {
>
>                    errorProvider1.SetError(textBox2, "Enter a valid
> Date2");
>                    textBox2.Focus();
>                }
>            }
>            else
>                errorProvider1.SetError(textBox2, "");
>        }
>
>
>                Here the focus is not staying back on the control if the
> validation fails and,error provider is not shown at the correct position.
>
>
> Thanks in advance,
> Jijesh
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Issues-with-Control-focus-and-error-provider-location-tp23939522p23939522.html
> Sent from the Mono - WinForms mailing list archive at Nabble.com.
>
> _______________________________________________
> Mono-winforms-list maillist  -  [email protected]
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>

_______________________________________________
Mono-winforms-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-winforms-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.