为什么表单挂在输入焦点? [英] Why the form hang at inputs focus ?
问题描述
i有xtraform(管理分支),其中包含一些输入和gridview。
加载表单后,我可以关注任何输入(ex : - CodeInput.Text)没有任何问题。但是当我点击 EditGridbtnREP 时,输入数据就会填满。
请注意: ad_branches之间存在关系桌子和许多其他桌子。
当我再次关注任何输入时,表格挂起,需要2-3分钟。回复。
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"));
}
}
}
我尝试了什么:
i创建新表单并逐个复制控件并且问题仍然存在
i尝试评论代码一个接一个,但同样的问题
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();
推荐答案
我试着逐一评论这些代码,但同样的问题
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".
这篇关于为什么表单挂在输入焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!