Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,
i have xtraform (to manage Branch ) that contains some inputs and gridview.
after loading the form , i can focus any input (ex:- CodeInput.Text )without any problems. but when i click EditGridbtnREP , the inputs filled with the data.

please Note: there are a relation between ad_branches table and many others tables.

when i focus any inputs again , the form hang , and take 2-3 min. to respond.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraSplashScreen;
using MrSales.MrSLanguages;
using MrSales.MrSModels;
using System.Data.Entity;
using System.Runtime.InteropServices;

namespace MrSales.MrSViews.CompanyConfig
{
    public partial class ManageBranches : DevExpress.XtraEditors.XtraForm
    {
        public int ID = 0;
        public ManageBranches()
        {

            SplashScreenManager.CloseForm(false);

            SplashScreenManager.ShowForm(this, typeof(waitForm), true, true, false);
            try { SplashScreenManager.Default.SetWaitFormDescription(strings.Creating_basic_components); } catch { }


            InitializeComponent();


            mrsalesdbEntities dbContext = ConnectionTools.OpenConn();
            try{ SplashScreenManager.Default.SetWaitFormDescription(strings.loading_branches_list); } catch { }
            ad_branchesBindingSource.DataSource = dbContext.ad_branches.ToList();   


            try { SplashScreenManager.Default.SetWaitFormDescription(strings.LOADING_company_data); } catch { }
            ad_company_dataBindingSource.DataSource = dbContext.ad_company_data.Local.ToBindingList();


            try { SplashScreenManager.Default.SetWaitFormDescription(strings.loading_Countries_Cities); } catch { }
            ad_countryBindingSource.DataSource = dbContext.ad_country.ToList();
            ad_cityBindingSource.DataSource = dbContext.ad_city.ToList();



        }
        //to drag form
        const int HT_CAPTION = 0x2;
        const int WM_NCLBUTTONDOWN = 0xA1;

        [DllImportAttribute("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
        [DllImportAttribute("user32.dll")]
        public static extern bool ReleaseCapture();



        private void ManageBranches_Load(object sender, EventArgs e)
        {
            
            SplashScreenManager.Default.SetWaitFormDescription(strings.loading_interface);

            //Func to Load All Basic And Requires Design Varibles 
            MrSControls.FormLoad.PublicDesign(this);
            CompanyInput.EditValue = 1;

            SplashScreenManager.CloseForm(false); 
        }

        private void CloseFrmBtn_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void HeaderPanel_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }

        private void EditGridbtnREP_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {

            ID = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "branche_ID"));
            CompanyInput.EditValue = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "comp_ID"));
            CodeInput.Text = Convert.ToString(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "branche_Code"));
            NameInput.Text = Convert.ToString(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "branche_Name"));
            StatusToggle.EditValue = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "branche_Status")) == 0 ? false : true;
            Mobile1Input.Text = Convert.ToString(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "branche_Mobile1"));
            Mobile2Input.Text = Convert.ToString(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "branche_Mobile2"));
            Mobile3Input.Text = Convert.ToString(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "branche_Mobile3"));
            PhoneInput.Text = Convert.ToString(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "branche_Phone"));
            AddressInput.Text = Convert.ToString(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "branche_Address"));
            CountryInput.EditValue = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Country"));
            CityInput.EditValue = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "City"));
        }
    }
}


What I have tried:

i created new form and copied the controls one by one and the problem still exist

i tried comment the codes one by one but the same issue

SplashScreenManager.CloseForm(false);

           SplashScreenManager.ShowForm(this, typeof(waitForm), true, true, false);
           try { SplashScreenManager.Default.SetWaitFormDescription(strings.Creating_basic_components); } catch { }


           InitializeComponent();


           mrsalesdbEntities dbContext = ConnectionTools.OpenConn();
           try{ SplashScreenManager.Default.SetWaitFormDescription(strings.loading_branches_list); } catch { }
           ad_branchesBindingSource.DataSource = dbContext.ad_branches.ToList();


           try { SplashScreenManager.Default.SetWaitFormDescription(strings.LOADING_company_data); } catch { }
           ad_company_dataBindingSource.DataSource = dbContext.ad_company_data.Local.ToBindingList();


           try { SplashScreenManager.Default.SetWaitFormDescription(strings.loading_Countries_Cities); } catch { }
           ad_countryBindingSource.DataSource = dbContext.ad_country.ToList();
           ad_cityBindingSource.DataSource = dbContext.ad_city.ToList();
Posted
Updated 15-May-19 12:48pm
v2
Comments
BillWoodruff 15-May-19 22:44pm    
Is there an error message ? Have you tried DevXpress support ?

If control actually returns, after several minutes, you need to look at what's happening with the database, perhaps write some logging code.

1 solution

Quote:
i tried comment the codes one by one but the same issue


Keep commenting. You're loading a lot of stuff in the constructor. You say the problem is after the "click": You're also fiddling with the mouse. Lot's of "splashing". Weird way of loading data entry fields (versus syncing to a current item in a DATA SOURCE).

I promise, at some point there will be "no issue" (when you finish commenting).

Or, you can "use the debugger".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900