Example #1
0
        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            GridViewCompany.ClearColumnsFilter();
            if (CompanyBindingSource.Current == null)
            {
                //fake query in order to create a link between the database table and the binding source
                CompanyBindingSource.DataSource = from opt in context.COMPANY where opt.CODE == "KJM9" select opt;
                CompanyBindingSource.AddNew();
                if (GridViewCompany.FocusedRowHandle == GridControl.AutoFilterRowHandle)
                {
                    GridViewCompany.FocusedRowHandle = GridViewCompany.RowCount - 1;
                }
                setValues();
                cODETextEdit.Focus();
                cODETextEdit.Properties.ReadOnly = false;
                GridViewCompany.Columns.ColumnByName(colName).OptionsColumn.AllowEdit = true;
                newRec = true;
                return;
            }

            cODETextEdit.Focus();

            //  bindingNavigatorPositionItem.Focus();  //trigger field leave event
            GridViewCompany.CloseEditor();
            temp = newRec;
            if (checkForms())
            {
                if (!temp)
                {
                    context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( COMPANY)CompanyBindingSource.Current);
                }
                CompanyBindingSource.AddNew();
                if (GridViewCompany.FocusedRowHandle == GridControl.AutoFilterRowHandle)
                {
                    GridViewCompany.FocusedRowHandle = GridViewCompany.RowCount - 1;
                }
                setValues();
                cODETextEdit.Focus();
                cODETextEdit.Properties.ReadOnly = false;
                GridViewCompany.Columns.ColumnByName(colName).OptionsColumn.AllowEdit = true;
                newRec = true;
            }
        }