1

I've a WinForm that contains Navigation menu that display UserControls. Now everything works fine except the form freezes when I try to open a Devexpress UserControl from another UserControl.

Here is the code I used:

private void btnOpenUserControl2_Click(object sender, EventArgs e)
{  
   UserControl2 uc2 = new UserControl2(ID);

   this.Parent.Controls.Add(uc2);
   uc2.Dock = DockStyle.Fill;
   this.Hide();
   uc2.Show(); 
}

What could be the possible reason?

aby
  • 810
  • 6
  • 21
  • 36

2 Answers2

0

the form freezes is most likely one of two things: in your UserControl2 you hndle an event ( for example form_Load), and in that event you have an infinity loop. the other reason is you have some handeled exception, or a long flow, very long flow, that cause your program to ran slow, so slow you think it's stuck.

in anyway it be very helpful if you share your UserControl2 code. but easier will be if you just pause the program while debugging it in VS when it get stuck and see where is it stucked. from there it should be fairly easy

No Idea For Name
  • 11,411
  • 10
  • 42
  • 70
  • You are right, I found out that binding DevExpress LookUpEdit control with more than 50,000 rows is taking longer than expected. Any idea how I should approach the problem? – aby Aug 02 '13 at 18:31
  • @aby, open another thread and run those 50,000 rows in that new thread(a background thread). that way the UI won't freeze. if you need a help doing that look here - http://stackoverflow.com/questions/363377/how-do-i-run-a-simple-bit-of-code-in-a-new-thread . and please accept my answer – No Idea For Name Aug 02 '13 at 19:05
0

The solution to this problem is to use the GridLookupEdit control in server mode instead. In this case, the gridLookupEdit will load only a small portion of data from the database and will continue loading data when you scroll the grid. To learn how to adjust the gridLookupEdit in server mode, please refer to Server Mode topic.

platon
  • 5,310
  • 1
  • 22
  • 24