473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C# Winform - Updating Combobox hangs application.

I have a winform with a combobox. This combobox's text is set to a value from the database (in this case, a number). In my code I take the number and convert it to the proper text, returning the value as the selecteditem for the combobox. This part works.

However, if I try to UPDATE the value in the combobox at runtime, I am able to select the new value, but after that I cannot do anything. I am unable to select any other element on my form (textboxes, comboboxes, etc). The program basically hangs and I have to exit. The new value in the problem combobox stays highlighted though, and kind of "sticks" there.

Any ideas are welcome.

Code is below.

Expand|Select|Wrap|Line Numbers
  1. int PATesting = Convert.ToInt32(comboBox73.Text);
  2.                 string TestStatus = " ";
  3.                 switch (PATesting)
  4.                 {
  5.                     case 0:
  6.                         TestStatus = "Assigned";
  7.                         break;
  8.                     case 1:
  9.                         TestStatus = "Working";
  10.                         break;
  11.                     case 2:
  12.                         TestStatus = "Code Submitted";
  13.                         break;
  14.                     case 3:
  15.                         TestStatus = "In Testing";
  16.                         break;
  17.                     case 4:
  18.                         TestStatus = "Passed";
  19.                         break;
  20.                     case 5:
  21.                         TestStatus = "Failed";
  22.                         break;
  23.                     case 6:
  24.                         TestStatus = "Hold";
  25.                         break;
  26.                     case 7:
  27.                         TestStatus = "In Production";
  28.                         break;
  29.                 }
  30.                 this.comboBox73.SelectedItem = TestStatus;
Apr 24 '08 #1
9 4143
Plater
7,872 Expert 4TB
My guess is you are doing something in the value changed (index/value/whatever changed) event for the combobox and in THAT event, also changing the value. Making a cycle.
Apr 24 '08 #2
Frinavale
9,735 Expert Mod 8TB
Have you tried using
Expand|Select|Wrap|Line Numbers
  1.  this.comboBox73.SelectedText = TestStatus;
?

-Frinny
Apr 24 '08 #3
Have you tried using
Expand|Select|Wrap|Line Numbers
  1.  this.comboBox73.SelectedText = TestStatus;
?

-Frinny

I have not tried that, but I will.


My guess is you are doing something in the value changed (index/value/whatever changed) event for the combobox and in THAT event, also changing the value. Making a cycle.
Actually, I don't have any events fire for that combobox. I do, for some other comboboxes on the same form, but not that one.
Apr 24 '08 #4
I have not tried that, but I will.
SelectedText yields the same result.

When it freezes up like that, I can still access the combobox menu and pick whatever i want, but i can't tab or click out of it. The only other menus I can access are the file and help (the only ones I have), and at that point I have to click file > exit to close the app.
Apr 24 '08 #5
Bump? I can't find anything like this on Google.
Apr 28 '08 #6
Plater
7,872 Expert 4TB
I don't think I understand how you populate the combobox.
You said it pulls from a database (Datasource property?) and that it sets the text to a number. Then you change these numbers to the text you actually want?
That seems sorta silly?
Seems to me like you should populate the combobox with the actual texts you want and then SELECT the index of the one from the number (so if the database returns a 2, you would have index 2 selected from the combobox, which should be your correct text displayed)
Apr 28 '08 #7
That seems sorta silly?
Seems to me like you should populate the combobox with the actual texts you want and then SELECT the index of the one from the number (so if the database returns a 2, you would have index 2 selected from the combobox, which should be your correct text displayed)
It does, but I'm not really seeing a way to implement what you're describing. My combobox has all my texts that I want - they're hardcoded in there. I don't see a way to associate each item with an index?

I'll look into this. Thanks for the reply.
Apr 29 '08 #8
Plater
7,872 Expert 4TB
int idx =ValueFromDataBase();
myCombobox.SelectedIndex=idx;
Apr 29 '08 #9
pootle
68
SelectedText yields the same result.

When it freezes up like that, I can still access the combobox menu and pick whatever i want, but i can't tab or click out of it. The only other menus I can access are the file and help (the only ones I have), and at that point I have to click file > exit to close the app.
You surely see something in the debugger when this blocking behaviour occurs. What is in the call stack of each thread?
Apr 29 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Niels | last post by:
Hello, I'm trying to get te index of a specific text in a ComboBox. The ComboBox is filled by searching for filenames in a directory. The text of the last item selected in the ComboBox is saved in...
1
by: Prem S | last post by:
Hi All I have a databound ComboBox control which is put into the second page of a tab control. When the form loads up, I databind the combo control and populate the control. When I go to...
6
by: nadeem_far | last post by:
Hello All, I am working on a .Net desktop application and I am having problem displaying a form. I am using C# and version 1.1 of the framework. here is how the code looks likes and I will...
5
by: Niels | last post by:
Hello, I'm trying to get te index of a specific text in a ComboBox. The ComboBox is filled by searching for filenames in a directory. The text of the last item selected in the ComboBox is saved...
3
by: WB | last post by:
Hi, I'm building my first Windows application using C#. My Windows application sends newsletter to our subscribers by email. Our newsletter is sort of "customized" so my application has to...
2
by: murdock | last post by:
I am having an issue with graphical corruption upon re-selecting a combobox which upon 'selected index change' event should list file names in that folder in a separate combobox. Here is the code:...
5
by: Joey | last post by:
Hi, I am using NFOP to generate PDF files from my web pages. The problem is that when i change the web.config, the page that is using NFOP hangs. I don't know if this is directly related to...
5
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.