Click here to Skip to main content
15,891,375 members

Why the form hang at inputs focus ?

Golden Basim asked:

Open original thread
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();
Tags: C#, Entity Framework, DevExpress

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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