private void OnTrackBarScroll(object sender, EventArgs e)
        {
            TrackBar trackBar = sender as TrackBar;

            if (trackBar.Tag == null)
            {
                return;
            }

            // For now, only update the labels of track bars we think are percentages.
            if (trackBar.Minimum == 0 && trackBar.Maximum == 100)
            {
                UpdateTrackBarLabel(trackBar);
            }

            NumericField f = trackBar.Tag as NumericField;

            if (trackBar.Value == 0 && !f.CanBeZero)
            {
                errorRestoSham.SetError(sender as Control, "Value cannot be zero.");
                return;
            }

            if (trackBar.Value > f.MaxValue || trackBar.Value < f.MinValue)
            {
                string err = string.Format("Value must be between {0} and {1}.", f.MinValue, f.MaxValue);
                errorRestoSham.SetError(sender as Control, err);
                return;
            }

            this[f.PropertyName] = trackBar.Value;
            Character.OnCalculationsInvalidated();
        }
        private void numericTextBox_Validating(object sender, CancelEventArgs e)
        {
            Control txtBox = sender as Control;

            if (txtBox.Tag == null)
            {
                return;
            }
            NumericField info = txtBox.Tag as NumericField;

            float  f;
            string szError = string.Empty;

            if (!float.TryParse(txtBox.Text, out f))
            {
                szError = "Please enter a numeric value";
            }
            else
            {
                if (f < info.MinValue || f > info.MaxValue)
                {
                    if (f == 0f && !info.CanBeZero)
                    {
                        if (info.MinValue == float.MinValue)
                        {
                            if (info.MaxValue == float.MaxValue)
                            {
                                szError = "Please enter a numeric value";
                            }
                            else
                            {
                                szError = "Please enter a number less than " + info.MaxValue.ToString();
                            }
                        }
                        else
                        {
                            if (info.MaxValue == float.MaxValue)
                            {
                                szError = "Please enter a number larger than " + info.MinValue.ToString();
                            }
                            else
                            {
                                szError = "Please enter a number between " + info.MinValue.ToString() + " and " +
                                          info.MaxValue.ToString();
                            }
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(szError))
            {
                e.Cancel = true;
                errorRestoSham.SetError(sender as Control, szError);
            }
        }
        private void numericTextBox_Validated(object sender, EventArgs e)
        {
            if (_bLoading || Character == null)
            {
                return;
            }

            Control txtBox = sender as Control;

            if (txtBox.Tag == null)
            {
                return;
            }
            NumericField info = txtBox.Tag as NumericField;

            this[info.PropertyName] = float.Parse(txtBox.Text);
            Character.OnCalculationsInvalidated();
        }