Thursday, June 12, 2014

Sender Parameter/ Common functions (C#)

Common text box validation function for all the text boxes within the same form.
Using Sender parameter to handle.   

   private void textBoxLongStalk_Validating(object sender, CancelEventArgs e)
        {
            TextBox txt = sender as TextBox;

            if (txt.Text != string.Empty)
            {
                if (isNumaric(txt) == false)
                {
                    e.Cancel = true;
                    txt.Select(0, txt.Text.Length);
                    numaricError(txt);
                }

                if (isGraterThanSampleSize(txt) == true)
                {
                    e.Cancel = true;
                    txt.Select(0, txt.Text.Length);
                    greaterThanSampleSizeError(txt);
                }

                displayRemainingBunchCount();
            }

        }

No comments:

Post a Comment

Postgress - Read a XML file from a postgress table XML column

SELECT xmltable.* FROM xmldata, XMLTABLE('//ROWS/ROW' PASSING data COLUMNS id int PATH ...