public virtual System.Windows.Forms.ComboBox MakeComboBox()
        {
            ComboLook cb = new ComboLook();

            cb.SetUpdateFieldIndex(this.nUpdatePos);
            return(cb);
        }
 protected override void OnCurrentCellChanged(EventArgs e)
 {
     try
     {
         base.OnCurrentCellChanged(e);
         if (bNoEvents || !pageLoaded)
         {
             return;
         }
         bool bRowChanged = false;
         if (nCurrentCellColumn != this.CurrentCell.ColumnNumber)
         {
             OnCellNumberChanged();
             nCurrentCellColumn = this.CurrentCell.ColumnNumber;
         }
         if (nCurrentRowIndex != this.CurrentRowIndex)
         {
             nCurrentRowIndex = this.CurrentRowIndex;
             bRowChanged      = true;
         }
         if (_query != null)
         {
             if (_query.Fields.Count > 0)
             {
                 for (int i = 0; i < _query.Fields.Count; i++)
                 {
                     if (cbx != null)
                     {
                         if (cbx[i] != null)
                         {
                             cbx[i].Visible = false;
                         }
                     }
                     if (bts != null)
                     {
                         if (bts[i] != null)
                         {
                             bts[i].Visible = false;
                         }
                     }
                 }
             }
         }
         if (currentCellInSynch())
         {
             sCurCaption = _query.Tables[0].Columns[nCurrentCellColumn].Caption;
             //					if( !bReadOnly && columnEditable(nCurrentCellColumn) )
             //					{
             if (cbx != null)
             {
                 if (cbx[nCurrentCellColumn] != null)
                 {
                     if (/*!fields[nCurrentCellColumn].ReadOnly &&*/ _query.Fields[nCurrentCellColumn].OleDbType != System.Data.OleDb.OleDbType.DBTimeStamp)
                     {
                         object v0 = this[nCurrentRowIndex, nCurrentCellColumn];
                         //									string sValue = clsProperty.ToString(v0);
                         System.Drawing.Rectangle rc = this.GetCurrentCellBounds();
                         cbx[nCurrentCellColumn].SetBounds(rc.Left, rc.Top, rc.Width, rc.Height);
                         ComboLook cbxLK = cbx[nCurrentCellColumn] as ComboLook;
                         if (cbxLK != null)
                         {
                             DataRowView rv;
                             for (int i = 0; i < cbxLK.Items.Count; i++)
                             {
                                 //											string sv;
                                 object v;
                                 rv = cbxLK.Items[i] as DataRowView;
                                 if (rv != null)
                                 {
                                     v = rv[0];
                                 }
                                 else
                                 {
                                     v = cbxLK.Items[i];
                                 }
                                 if (LogicExp.Compare(v, enumLogicType2.Equal, v0))
                                 {
                                     cbxLK.bNoEvent      = true;
                                     cbxLK.SelectedIndex = i;
                                     cbxLK.bNoEvent      = false;
                                     break;
                                 }
                             }
                             if (cbxLK.SelectedIndex < 0)
                             {
                                 cbxLK.SetSelectedIndex(v0);
                             }
                             //
                         }
                         else
                         {
                             cbx[nCurrentCellColumn].SelectedIndex = -1;
                             if (this[nCurrentRowIndex, nCurrentCellColumn] != null)
                             {
                                 cbx[nCurrentCellColumn].Text = ValueConvertor.ToString(v0);
                             }
                             else
                             {
                                 cbx[nCurrentCellColumn].Text = "";
                             }
                         }
                         cbx[nCurrentCellColumn].Visible = true;
                         cbx[nCurrentCellColumn].BringToFront();
                     }
                 }
             }
             if (!ReadOnly && columnEditable(nCurrentCellColumn))
             {
                 if (bts != null)
                 {
                     if (bts[nCurrentCellColumn] != null)
                     {
                         if (/*!fields[nCurrentCellColumn].ReadOnly &&*/ _query.Fields[nCurrentCellColumn].OleDbType != System.Data.OleDb.OleDbType.DBTimeStamp)
                         {
                             System.Drawing.Rectangle rc = this.GetCurrentCellBounds();
                             bts[nCurrentCellColumn].SetBounds(rc.Left + rc.Width - 20, rc.Top, 20, rc.Height);
                             bts[nCurrentCellColumn].Visible = true;
                             bts[nCurrentCellColumn].BringToFront();
                             if (_query.Fields[nCurrentCellColumn].editor != null)
                             {
                                 if (this[nCurrentRowIndex, nCurrentCellColumn] == null)
                                 {
                                     _query.Fields[nCurrentCellColumn].editor.currentValue = "";
                                 }
                                 else
                                 {
                                     _query.Fields[nCurrentCellColumn].editor.currentValue = this[nCurrentRowIndex, nCurrentCellColumn].ToString();
                                 }
                             }
                         }
                     }
                 }
             }
             if (bRowChanged)
             {
                 System.Data.DataRow dw = CurrentRow;
                 if (dw != null)
                 {
                     for (int i = 0; i < _query.Fields.Count; i++)
                     {
                         _query.Fields[i].Value = dw[i];
                     }
                 }
                 onRowIndexChanged();
                 if (CurrentRowIndexChange != null)
                 {
                     CurrentRowIndexChange(this, new System.EventArgs());
                 }
             }
         }
         //else
         //{
         //    if (_query != null)
         //    {
         //        if (_query.Tables.Count > 0)
         //        {
         //            if (_query.Tables[0] != null)
         //            {
         //                if (nCurrentRowIndex == 0 && _query.Tables[0].Rows.Count == 0)
         //                {
         //                }
         //            }
         //        }
         //    }
         //}
     }
     catch (Exception er)
     {
         FormLog.NotifyException(er);
     }
 }
        void onLookupSelected(object sender, System.EventArgs e)
        {
//			int xx= 0;

            ComboLook cb = (ComboLook)sender;

            if (cb.bNoEvent)
            {
                return;
            }
            int n = cb.SelectedIndex;

            if (n >= 0)
            {
                object Value = cb.GetLookupData();
                if (currentCellInSynch())
                {
                    bool bMatch = false;
                    if (cbx != null && nCurrentCellColumn >= 0 && nCurrentCellColumn < cbx.Length)
                    {
                        bMatch = (cbx[nCurrentCellColumn] == sender);
                    }
                    try
                    {
                        System.Data.DataRow dw = CurrentRow;
                        if (bMatch && dw != null && _query.Fields[nCurrentCellColumn].editor != null)
                        {
                            DataBind           databind = null;
                            DataEditorLookupDB lk       = _query.Fields[nCurrentCellColumn].editor as DataEditorLookupDB;
                            if (lk != null)
                            {
                                databind = lk.valuesMaps;
                            }
                            DataRow rv = Value as DataRow;
                            if (databind != null && rv != null)
                            {
                                if (databind.AdditionalJoins != null && databind.AdditionalJoins.StringMaps != null)
                                {
                                    for (int i = 0; i < databind.AdditionalJoins.StringMaps.Length; i++)
                                    {
                                        dw[databind.AdditionalJoins.StringMaps[i].Field1] = rv[databind.AdditionalJoins.StringMaps[i].Field2];
                                    }
                                }
                                onLookup();
                            }
                            else
                            {
                                if (rv != null)
                                {
                                    Value = rv[1];
                                }
                                bool bEQ  = false;
                                int  nPos = cb.GetUpdateFieldIndex();
                                if (nPos < 0)
                                {
                                    nPos = nCurrentCellColumn;
                                }
                                if (Value == null)
                                {
                                    if (dw[nPos] == null)
                                    {
                                        bEQ = true;
                                    }
                                }
                                else if (Value == System.DBNull.Value)
                                {
                                    bEQ = (dw[nPos] == System.DBNull.Value);
                                }
                                else if (Value.Equals(dw[nPos]))
                                {
                                    bEQ = true;
                                }
                                if (!bEQ)
                                {
                                    dw.BeginEdit();
                                    dw[nPos] = Value;
                                    dw.EndEdit();
                                    dw[nCurrentCellColumn] = ValueConvertor.ToObject(cb.Text, _query.Tables[0].Columns[nCurrentCellColumn].DataType);
                                }
                                //							if(xx>=0)
                                //								return;
                                //							bNoEvents = true;
                                //							cb.Visible = false;
                                //							bNoEvents = false;
                                //							onRowIndexChanged();

                                if (!bEQ)
                                {
                                    onLookup();
                                }
                            }
                        }
                    }
                    catch (Exception er)
                    {
                        FormLog.NotifyException(er);
                    }
                }
            }
        }