protected void setFieldEditor(int i)
 {
     if (_query == null)
     {
         return;
     }
     if (i < 0 || i >= _query.Fields.Count)
     {
         return;
     }
     if (_query.Fields[i].editor != null)
     {
         DataEditorButton bn = _query.Fields[i].editor as DataEditorButton;
         if (bn != null)
         {
             bts[i] = bn.MakeButton(this.FindForm());
             if (bts[i] != null)
             {
                 bts[i].Parent  = this;
                 bts[i].Visible = false;
                 _query.Fields[i].editor.OnPickValue += new fnOnPickValue(onPickValueByButton);
             }
         }
         else
         {
             DataEditorLookupYesNo LK = _query.Fields[i].editor as DataEditorLookupYesNo;
             if (LK != null)
             {
                 cbx[i] = LK.MakeComboBox();
                 if (cbx[i] != null)
                 {
                     cbx[i].Parent  = this;
                     cbx[i].Visible = false;
                     cbx[i].SelectedIndexChanged += new System.EventHandler(onLookupSelected);
                 }
             }
         }
     }
     else
     {
         cbx[i] = null;
         bts[i] = null;
     }
 }
        public virtual void ApplyStyle()
        {
            //btSave.Visible = (!bReadOnly);
            if (_query == null)
            {
                return;
            }
            if (_query.Fields.Count == 0)
            {
                return;
            }
            int i;
            int n = _query.Fields.Count;

            if (cbx != null)
            {
                for (i = 0; i < cbx.Length; i++)
                {
                    try
                    {
                        this.Controls.Remove(cbx[i]);
                    }
                    catch
                    {
                    }
                    cbx[i] = null;
                }
            }
            if (bts != null)
            {
                for (i = 0; i < bts.Length; i++)
                {
                    try
                    {
                        this.Controls.Remove(bts[i]);
                    }
                    catch
                    {
                    }
                    bts[i] = null;
                }
            }
            cbx = new System.Windows.Forms.ComboBox[n];
            bts = new System.Windows.Forms.Button[n];
            DataGridColumnStyle TextCol;

            myGridTableStyle             = new DataGridTableStyle();
            myGridTableStyle.MappingName = DataTableName;
            //			myGridTableStyle.AlternatingBackColor = System.Drawing.Color.LightPink;
            //			int j=0;

            string cap;

            for (i = 0; i < _query.Fields.Count; i++)
            {
                if (ReadOnly || !EPField.IsBinary(_query.Fields[i].OleDbType))
                {
                    if (_query.Fields[i].OleDbType == System.Data.OleDb.OleDbType.Boolean)
                    {
                        TextCol = new DataGridBoolColumn();
                    }
                    else
                    {
                        TextCol = new TextColumnStyle(_query.Fields[i].HeaderAlignment);// new DataGridTextBoxColumn();
                        //						((DataGridTextBoxColumn)TextCol).TextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
                        ((DataGridTextBoxColumn)TextCol).TextBox.DoubleClick += new EventHandler(TextBox_DoubleClick);
                        ((DataGridTextBoxColumn)TextCol).TextBox.Click       += new EventHandler(TextBox_Click);
                        ((DataGridTextBoxColumn)TextCol).TextBox.GotFocus    += new EventHandler(TextBox_GotFocus);
                        ((TextColumnStyle)TextCol).Format = _query.Fields[i].Format;
                        if (NullText != null)
                        {
                            ((TextColumnStyle)TextCol).NullText = NullText;
                        }
                    }

                    TextCol.MappingName = _query.Fields[i].Name;
                    TextCol.Alignment   = _query.Fields[i].TxtAlignment;
                    cap = _query.Fields[i].FieldCaption;
                    if (string.IsNullOrEmpty(cap))
                    {
                        cap = _query.Fields[i].Name;
                    }
                    TextCol.HeaderText = cap;
                    if (ReadOnly)
                    {
                        TextCol.ReadOnly = true;
                    }
                    else
                    {
                        if (_query.Fields[i].IsIdentity || _query.Fields[i].ReadOnly ||
                            EPField.IsBinary(_query.Fields[i].OleDbType) ||
                            _query.Fields[i].OleDbType == System.Data.OleDb.OleDbType.DBTimeStamp)
                        {
                            TextCol.ReadOnly = true;
                        }
                    }
                    if (_query.Fields[i].Visible)
                    {
                        TextCol.Width = _query.Fields[i].ColumnWidth;
                    }
                    else
                    {
                        TextCol.Width = 0;
                    }

                    myGridTableStyle.GridColumnStyles.Add(TextCol);
                    if (_query.Fields[i].editor != null)
                    {
                        DataEditorButton bn = _query.Fields[i].editor as DataEditorButton;
                        if (bn != null)
                        {
                            bts[i] = bn.MakeButton(this.FindForm());
                            if (bts[i] != null)
                            {
                                bts[i].Parent  = this;
                                bts[i].Visible = false;
                                _query.Fields[i].editor.OnPickValue += new fnOnPickValue(onPickValueByButton);
                            }
                        }
                        else
                        {
                            DataEditorLookupYesNo LK = _query.Fields[i].editor as DataEditorLookupYesNo;
                            if (LK != null)
                            {
                                cbx[i] = LK.MakeComboBox();
                                if (cbx[i] != null)
                                {
                                    cbx[i].Parent  = this;
                                    cbx[i].Visible = false;
                                    cbx[i].SelectedIndexChanged += new System.EventHandler(onLookupSelected);
                                }
                            }
                        }
                    }
                    //					j++;
                }
            }
            //this.ReadOnly = bReadOnly;
            this.TableStyles.Clear();
            this.TableStyles.Add(myGridTableStyle);
        }