[Mono-winforms-list] Issues with Control focus and error provider location
Carlos Alberto Cortez
calberto.cortez at gmail.com
Thu Jun 11 12:40:16 EDT 2009
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 <incubator125 at hotmail.com>
>
> 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 - Mono-winforms-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-winforms-list/attachments/20090611/9abcb2eb/attachment-0001.html
More information about the Mono-winforms-list
mailing list