protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
        {
            bool enabled = true;
            if(CheckCellEnabled != null)
            {
                DataGridEnableEventArgs e = new DataGridEnableEventArgs(rowNum, _col, enabled);
                CheckCellEnabled(this, e);
                if(!e.EnableValue)
                    backBrush = Brushes.LightGray;
            }

            //changing for color
            Brush  enabledcolor = null;
            if(CheckCellColor != null)
            {
                DataGridCellColorEventArgs  e = new DataGridCellColorEventArgs(rowNum, _col, enabledcolor);
                CheckCellColor(this, e);
                if(e.EnableColor != null)
                    backBrush = e.EnableColor  ;
            }

            //end

            base.Paint (g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
        }
        protected override void Edit(CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible)
        {
            bool enabled = true;

            if(CheckCellEnabled != null)
            {
                DataGridEnableEventArgs et = new DataGridEnableEventArgs(rowNum, _col, enabled);
                CheckCellEnabled(this, et);
                enabled = et.EnableValue;
            }

            if(enabled)
            {
                base.Edit(source,rowNum,bounds,readOnly,instantText,cellIsVisible);

                if(cellIsVisible)
                {
                    _rowNum = rowNum;
                    _source = source;

                    ColumnDateTimePicker.Parent = this.TextBox.Parent;
                    Rectangle rectTemp = this.DataGridTableStyle.DataGrid.GetCurrentCellBounds();
                    ColumnDateTimePicker.Location = rectTemp.Location;

                    ColumnDateTimePicker.Size = new Size(this.TextBox.Size.Width,this.TextBox.Height);

                    if(this.TextBox.Text.Trim() != "")
                        ColumnDateTimePicker.Value = Convert.ToDateTime(this.TextBox.Text);
                    else
                        ColumnDateTimePicker.Value = DateTime.MinValue;

                    this.TextBox.Visible = false;

                    ColumnDateTimePicker.Visible = true;
                    ColumnDateTimePicker.ReadOnly = this.TextBox.ReadOnly;

                    this.DataGridTableStyle.DataGrid.Scroll += new EventHandler(HandleScroll);

                    ColumnDateTimePicker.Show();
                    ColumnDateTimePicker.BringToFront();
                    ColumnDateTimePicker.Focus();
                }
                else
                    ColumnDateTimePicker.Hide();
            }
            else
                ColumnDateTimePicker.Enabled = false;
        }
        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight)
        {
            //can remove this if you don't want to vary the color of diabled cells
            bool enabled = true;
            if(CheckCellEnabled != null)
            {
                DataGridEnableEventArgs e = new DataGridEnableEventArgs(rowNum, _col, enabled);
                CheckCellEnabled(this, e);
                if(!e.EnableValue)
                    backBrush = Brushes.LightGray;
                if(_boolGetColor)
                    foreBrush = new SolidBrush(_getColorRowCol(rowNum,this._col));
            }

            //changing for color
            Brush  enabledcolor = null;
            if(CheckCellColor != null)
            {
                DataGridCellColorEventArgs  e = new DataGridCellColorEventArgs(rowNum, _col, enabledcolor);
                CheckCellColor(this, e);
                if(e.EnableColor != null)
                    backBrush = e.EnableColor  ;
            }

            //end
            base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
        }
        protected override void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible)
        {
            try
            {
                bool enabled = true;

                if(CheckCellEnabled != null)
                {
                    DataGridEnableEventArgs et = new DataGridEnableEventArgs(rowNum, _col, enabled);
                    CheckCellEnabled(this, et);
                    enabled = et.EnableValue;
                }

                if(enabled)
                {
                    base.Edit(source,rowNum, bounds, readOnly, instantText , cellIsVisible);

                    _rowNum = rowNum;
                    _source = source;

                    bounds.Offset(xMargin,yMargin);
                    bounds.Width -= xMargin * 2;
                    bounds.Height -= yMargin;

                    this.TextBox.TabStop = true;
                    ColumnComboBox.Bounds = bounds;
                    ColumnComboBox.TabStop = true;
                    ColumnComboBox.Enabled = true;
                    ColumnComboBox.Parent = this.TextBox.Parent;
                    Rectangle rect = this.DataGridTableStyle.DataGrid.GetCurrentCellBounds();
                    ColumnComboBox.Location = rect.Location;
                    ColumnComboBox.Size = new Size(this.TextBox.Size.Width, ColumnComboBox.Size.Height);
                    //ColumnComboBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
                    ColumnComboBox.SelectedIndex = ColumnComboBox.FindStringExact(this.TextBox.Text);
                    ColumnComboBox.Text =  this.TextBox.Text;
                    this.TextBox.Visible = false;
                    ColumnComboBox.Visible = true;

                    ColumnComboBox.ReadOnly = this.TextBox.ReadOnly;

                    this.DataGridTableStyle.DataGrid.Scroll += new EventHandler(HandleScroll);

                    ColumnComboBox.BringToFront();
                    ColumnComboBox.Focus();
                }
                else
                {
                    ColumnComboBox.Enabled = false;
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message + " - " + ex.Source);
            }
        }
        protected override void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible)
        {
            try
            {
                bool enabled = true;

                if (CheckCellEnabled != null)
                {
                    DataGridEnableEventArgs et = new DataGridEnableEventArgs(rowNum, _col, enabled);
                    CheckCellEnabled(this, et);
                    enabled = et.EnableValue;
                }

                if (enabled)//&& _keyTrapTextBox.Focused == false )
                {
                    _rowNum = rowNum;
                    _source = source;
                    _RowCount = source.Count;

                    try
                    {
                        base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
                    }
                    catch (Exception ex)
                    {
                        string str = ex.ToString();
                    }

                    if (_txtType == clsTxtBox.TypeEnum.Float)
                    {
                        if (_keyTrapTextBox.isCurrency)
                        {
                            _keyTrapTextBox.MaxLength = _keyTrapTextBox.GetNoofCommas() + _intPrecision + _decPrecision + 1;
                        }
                        else
                        {
                            _keyTrapTextBox.MaxLength = _intPrecision + _decPrecision + 1;
                        }
                    }
                    else if (_txtType == clsTxtBox.TypeEnum.Integer)
                    {
                        if (_keyTrapTextBox.isCurrency)
                        {
                            _keyTrapTextBox.MaxLength = _keyTrapTextBox.GetNoofCommas() + _intPrecision;
                        }
                        else
                        {
                            _keyTrapTextBox.MaxLength = _intPrecision;
                        }
                    }
                    else
                        _keyTrapTextBox.MaxLength = this.TextBox.MaxLength;

                    _keyTrapTextBox.Parent = this.TextBox.Parent;
                    _keyTrapTextBox.Location = this.TextBox.Location;
                    _keyTrapTextBox.Size = this.TextBox.Size;
                    _keyTrapTextBox.Height = this.TextBox.Height;
                    _keyTrapTextBox.Width = this.TextBox.Width;

                    _keyTrapTextBox.Text = this.TextBox.Text;

                    if (_txtType == clsTxtBox.TypeEnum.Integer || _txtType == clsTxtBox.TypeEnum.Float)
                    {
                        _keyTrapTextBox.TextAlign = HorizontalAlignment.Right;
                        this.TextBox.TextAlign = HorizontalAlignment.Right;
                        this.Alignment = HorizontalAlignment.Right;
                    }

                    _keyTrapTextBox.ReadOnly = this.TextBox.ReadOnly;
                    _keyTrapTextBox.ForeColor = this.TextBox.ForeColor;

                    this.TextBox.Visible = false;
                    _keyTrapTextBox.Visible = true;
                    _keyTrapTextBox.BringToFront();
                    _keyTrapTextBox.Focus();
                    _keyTrapTextBox.SelectAll();

                    //if (_txtType == clsTxtBox.TypeEnum.Integer || _txtType == clsTxtBox.TypeEnum.Float)
                    //{
                    //    _keyTrapTextBox.TextAlign = HorizontalAlignment.Right;
                    //    this.TextBox.TextAlign = HorizontalAlignment.Right;
                    //    this.Alignment = HorizontalAlignment.Right;
                    //}
                }
            }
            catch
            {
                MessageBox.Show("EDIT");
            }
        }
        //protected override void OnEditingControlShowing(DataGridViewEditingControlShowingEventArgs e)
        //{
        //    e.CellStyle.BackColor = Color.White;
        //    base.OnEditingControlShowing(e);
        //}
        private void SetEnableValues(object sender, DataGridEnableEventArgs e)
        {
            if(CheckDisableColumn(e.Column) && e.Row < intLoadRowCount)
            {
                e.EnableValue = false;
            }
            else
            {
                e.EnableValue = true;
            }

            #region For Cell Enabling and Disabling

            #endregion
        }
 private void EnableImmediateCols(object sender, DataGridEnableEventArgs e)
 {
     if(CheckEnableImmediate(e.Column))
     {
         e.EnableValue = true;
     }
 }
 private void EnableCell(object sender,DataGridEnableEventArgs e)
 {
     if((e.Column == _toggleCol && e.Row == _toggleRow) || CheckEnableCols(e.Row,e.Column))
         e.EnableValue = true;
 }
        /// <summary>
        ///To enable the columns in the datagrid.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetEnableValues(object sender, DataGridEnableEventArgs e)
        {
            if(CheckDisableColumn(e.Column) && e.Row < intLoadRowCount)
            {
                e.EnableValue = false;
            }
            else
            {
                e.EnableValue = true;
            }

            #region For Cell Enabling and Disabling

            //			for(int i=0; i < cellDisableList.Count; i++)
            //			{
            //				DataGridCellDisableEnableEventArgs obj = (DataGridCellDisableEnableEventArgs)cellDisableList[i];
            //
            //				if((obj.Column == e.Column) && ( obj.Row == e.Row))
            //				{
            //					e.EnableValue = false;
            //				}
            //			}
            //

            #endregion
        }