/// <summary> /// If the control passed as an argument does not store a valid double then it is cleared /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MyValidationDouble(object sender, CancelEventArgs e) { string MyValue = (sender as TextBox).Text; if (MyStringOperations.IsValidDouble(MyValue) == false) { MessageBox.Show("Wrong value"); e.Cancel = true; } (sender as TextBox).BackColor = Color.Yellow; }
/// <summary> /// Checks if the grid contains valid cells /// </summary> /// <returns></returns> public bool CheckState() { DateTime TimeOne = DateTime.Now; // GeneralClass. for (int ColumnIterator = 1; ColumnIterator <= MyGridView2.Columns.Count; ColumnIterator++) { for (int RowIterator = 1; RowIterator <= MyGridView2.RowCount; RowIterator++) { string MyValue = MyGridView2[ColumnIterator - 1, RowIterator - 1].Value.ObjectToString(); if ((MyStringOperations.IsValidDouble(MyValue) == false) && (DoubleColumns.Contains(ColumnIterator))) { MessageBox.Show("Wrong value inside the column " + Convert.ToString(ColumnIterator) + ", the row " + Convert.ToString(RowIterator)); } } } DateTime TimeTwo = DateTime.Now; TimeSpan MySpan = (TimeTwo - TimeOne); return(true); }