public bool DesignGrid(string strProcedureName, ref string strErr)
        {
            try
            {
                this.AutoGenerateColumns = false;
                strProcName = strProcedureName;

                Query objQuery = new Query();

                if (ProcParamNames.Count > 0)
                {
                    string[] arrStrProcParamNames = new string[ProcParamNames.Count];
                    string[] arrStrProcParamValues = new string[ProcParamNames.Count];
                    for (int i = 0; i < ProcParamNames.Count; i++)
                    {
                        arrStrProcParamNames[i] = ProcParamNames[i].ToString();
                        arrStrProcParamValues[i] = ProcParamValues[i].ToString();
                    }
                    objQuery.SetInputParameterNames(strProcedureName, arrStrProcParamNames);
                    objQuery.SetInputParameterValues(arrStrProcParamValues);
                }
                objQuery.SetOutputParameterNames(strProcedureName, "CRITERIA");

                DataSet ds = objQuery.ExecuteQueryProcedure(strProcedureName);

                dtReadOnlyGrid = ds.Tables[0].Copy();
                ds.Dispose();
                //Changing For New Component
                //_BSource = new BindingSource(dtReadOnlyGrid, null);
                intColCount = dtReadOnlyGrid.Columns.Count;
                strColNames = new string[intColCount];

                for (int i = 0; i < intColCount; i++)
                    strColNames[i] = dtReadOnlyGrid.Columns[i].ColumnName;

                string[] strHeadings = new string[intColCount];

                ////**** Creating the Header text by replacing the Underscore(_)
                ////**** Symbol with the Space ( ).

                clsLanguage objLang = new clsLanguage();

                for (int i = 0; i < intColCount; i++)
                {
                    strHeadings[i] = strColNames[i].Replace("_", " ");

                    if (strLangID != null && strColNames[i].IndexOf("MASK_") < 0)
                    {
                        if (strLangID.Length >= intColCount)
                        {
                            string strTmp = objLang.LanguageString(strLangID[i]);
                            if (strTmp == "*****")
                                strHeadings[i] = "** " + strHeadings[i];
                            else
                                strHeadings[i] = strTmp;
                        }
                        else
                        {
                            if (strLangID.Length > i)
                            {
                                string strTmp = objLang.LanguageString(strLangID[i]);

                                if (strTmp == "*****")
                                    strHeadings[i] = "** " + strHeadings[i];
                                else
                                    strHeadings[i] = strTmp;
                            }
                            else
                            {
                                strHeadings[i] = "** " + strHeadings[i];
                            }
                        }
                    }
                    else
                    {
                        strHeadings[i] = "** " + strHeadings[i];
                    }
                }

                if (objLang != null)
                    objLang.Dispose();

                ////**** If the Default design is false then setting Colors for that Grid

                //this.reEntrent = true;
                //Changing For New Component
               // this.DataSource = dtReadOnlyGrid;
                //this.DataSource = dtReadOnlyGrid;
                //this.reEntrent = false;
                if (SetDefault == true)
                {

                    //DataGridViewCellStyle headerstyle=new DataGridViewCellStyle();
                    //headerstyle.BackColor= System.Drawing.Color.Linen;
                    //headerstyle.ForeColor=System.Drawing.Color.Navy;
                    //this.GridColor = System.Drawing.Color.Silver;
                    //this.ColumnHeadersDefaultCellStyle.ApplyStyle(headerstyle);

                }
                else
                {
                    //this.ColumnHeadersDefaultCellStyle.BackColor = System.Drawing.Color.LightSteelBlue;
                    //this.ColumnHeadersDefaultCellStyle.ForeColor = System.Drawing.Color.Navy;
                    //this.GridColor = System.Drawing.Color.Silver;

                }

                ////**** To incorporate the Font the in DataGrid Cell.

                 intVisibleColumnCount = 0;
                 if (this.Columns.Count > 0)
                 {
                     this.Columns.Clear();
                 }
                for (int i = 0; i < intColCount; i++)
                {
                    if (strColNames[i].ToUpper().IndexOf("MASK") == 0)
                        continue;

                    intVisibleColumnCount++;
                    DataGridViewTextBoxColumn dgTBCol = new DataGridViewTextBoxColumn();
                    dgTBCol.DataPropertyName = dtReadOnlyGrid.Columns[i].ColumnName;
                    dgTBCol.HeaderText = strHeadings[i];
                    this.Columns.Add(dgTBCol);

                    //this.Columns[this.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;

                }
                //Changing For New Component
                //BindingCompleted = true;
                //clsReadOnlyGrid_BindingContextChanged(null, null);
               // this.Font = new Font(this.Font, FontStyle.Regular);
                this.ScrollBars = ScrollBars.Both;
                //this.AutoSize = true;
                this.DataSource = dtReadOnlyGrid;
                return true;
            }
            catch (Exception ex)
            {
                strErr = ex.Message + " - " + ex.Source;
                //return false;
                if (strErr == "Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function. - System.Windows.Forms")
                {
                    strErr = "";
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Executes a procedure for populating the treegridview
        /// </summary>
        /// <param name="SQLProcName">Procedure Name/SQL query string</param>
        /// <param name="isSQL">true if the supplied 'SQLProcName' if SQL query;else false</param>
        /// <param name="strErrMsg">Error message to be returned</param>
        /// <returns></returns>
        private bool ExecuteProcedure(string SQLProcName, bool isSQL, ref string strErrMsg)
        {
            try
            {
                Query objQuery = new Query();

                if (!isSQL)
                {
                    string[] arrStrProcParamNames = new string[0];
                    string[] arrStrProcParamValues = new string[0];
                    if (ProcParamNames.Count - arlOutParam.Count > 0)
                    {
                        arrStrProcParamNames = new string[ProcParamNames.Count - arlOutParam.Count];
                        arrStrProcParamValues = new string[ProcParamNames.Count - arlOutParam.Count];
                        for (int i = 0; i < ProcParamNames.Count; i++)
                        {
                            if (ProcParamValues[i] != null)
                            {
                                arrStrProcParamNames[i] = ProcParamNames[i].ToString();
                                arrStrProcParamValues[i] = ProcParamValues[i].ToString();
                            }
                        }
                        objQuery.SetInputParameterNames(SQLProcName, arrStrProcParamNames);
                        objQuery.SetInputParameterValues(arrStrProcParamValues);
                    }

                    arrStrProcParamNames = new string[arlOutParam.Count];
                    arrStrProcParamValues = new string[arlOutParam.Count];
                    int iOutParamIndex = 0;
                    for (int i = 0; i < ProcParamNames.Count; i++)
                    {
                        if (ProcParamValues[i] == null)
                        {
                            arrStrProcParamNames[iOutParamIndex++] = ProcParamNames[i].ToString();
                        }
                    }
                    objQuery.SetOutputParameterNames(SQLProcName, arrStrProcParamNames);

                    dsSource = objQuery.ExecuteQueryProcedure(SQLProcName);
                }
                else
                {
                    dsSource = objQuery.ExecuteQueryCommand(SQLProcName);
                }

                dtSource = dsSource.Tables[0].Copy();
                dsSource.Dispose();

                intColCount = dtSource.Columns.Count;
                strColNames = new string[intColCount];

                for (int i = 0; i < intColCount; i++)
                    strColNames[i] = dtSource.Columns[i].ColumnName;

                if (isSQL == false)
                {
                    strProcOutValue = new string[arlOutParam.Count];
                    for (int i = 0; i < arlOutParam.Count; i++)
                    {
                        strProcOutValue[i] = objQuery.GetOutputParameterValue(arlOutParam[i].ToString());
                    }
                }

                dtSource = dsSource.Tables[0];

                dvSource = dtSource.DefaultView;

                dvSource.AllowNew = false;
                intTotalRowCount = dvSource.Count;					//INDRANIL

                //dtSource.Columns.Add("MASK_LOAD_COL_VALUE");

                //for (int i = 0; i < dtSource.Rows.Count; i++)
                //    dtSource.Rows[i]["MASK_LOAD_COL_VALUE"] = "0";

                intColCount = dtSource.Columns.Count - 1;

                //MyGridTextBoxColumn._RowCount = dtSource.Rows.Count;

                ChangeDataTable();

                return true;
            }
            catch (Exception ex)
            {
                strErrMsg = ex.Message + " - " + ex.Source;
                return false;
            }
        }
        public bool PopulateGrid(ref string strErr)
        {
            try
            {
                Query objQuery = new Query();

                string[] arrStrProcParamNames = new string[ProcParamNames.Count];
                string[] arrStrProcParamValues = new string[ProcParamNames.Count];
                for (int i = 0; i < ProcParamNames.Count; i++)
                {
                    arrStrProcParamNames[i] = ProcParamNames[i].ToString();
                    arrStrProcParamValues[i] = ProcParamValues[i].ToString();
                }
                objQuery.SetInputParameterNames(strProcName, arrStrProcParamNames);
                objQuery.SetInputParameterValues(arrStrProcParamValues);
                objQuery.SetOutputParameterNames(strProcName, "CRITERIA");

                DataSet ds = objQuery.ExecuteQueryProcedure(strProcName);

                dtReadOnlyGrid = ds.Tables[0].Copy();

                intColCount = dtReadOnlyGrid.Columns.Count;
                strColNames = new string[intColCount];

                for (int i = 0; i < intColCount; i++)
                    strColNames[i] = dtReadOnlyGrid.Columns[i].ColumnName;
                // CurrencyManager cm = (CurrencyManager)this.BindingContext[this.DataSource];
                //((DataView)cm.List).AllowNew = true;
                //((DataView)cm.List).AllowNew = false;
                this.DataBindings.Clear();
                //this.Rows.Clear();
                //this.AllowUserToAddRows = false;
                this.reEntrent = true;
                this.MultiSelect = false;
                //this.DataSource = null;
                this.DataSource = dtReadOnlyGrid;
                this.reEntrent = false;
                //this.AllowUserToAddRows = true;
                //((DataView)cm.List).AllowNew = false;
                ds.Dispose();

                this.AutoSize = true;

                RowCount = dtReadOnlyGrid.Rows.Count;
                return true;
            }
            catch (Exception ex)
            {
                strErr = ex.Message + " - " + ex.Source;
                return false;
            }
        }