473,811 Members | 3,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Winform - Updating Combobox hangs application.

24 New Member
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 4174
Plater
7,872 Recognized Expert Expert
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 Recognized Expert Moderator Expert
Have you tried using
Expand|Select|Wrap|Line Numbers
  1.  this.comboBox73.SelectedText = TestStatus;
?

-Frinny
Apr 24 '08 #3
somacore
24 New Member
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
somacore
24 New Member
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
somacore
24 New Member
Bump? I can't find anything like this on Google.
Apr 28 '08 #6
Plater
7,872 Recognized Expert Expert
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
somacore
24 New Member
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 Recognized Expert Expert
int idx =ValueFromDataB ase();
myCombobox.Sele ctedIndex=idx;
Apr 29 '08 #9
pootle
68 New Member
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
6702
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 a textfile in the OnExit Event of the Mainform. While loading the Mainform I want the text that was saved in the file to be compared with the items in the ComboBox ad get the index of the found item, so that I can set it as selected. I...
1
2063
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 change the tab page to the second page, the application hangs...becoming completely non-responsive. If I populate the combo control with no databinding, I can change to
6
4096
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 appreciate if someone can tell me how to resolve this problem. Main ( Args ) { Form1 f1 = new Form1();
5
18479
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 a textfile in the OnExit Event of the Mainform. While loading the Mainform I want the text that was saved in the file
3
1943
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 build the newsletter for each individual subscriber before sending it out. Now the whole newsletter sending process to all the subscribers is a very long process and I'd like to keep my users updated throughout the whole time. I'd like to accomplish...
2
1623
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: private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { IniFile INI = new IniFile(@"c:\\data\TM.ini"); string MisFileDir = INI.IniReadValue("Main", "MisFileDir");
5
1536
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 NFOP, however i would like to know if i can make a workaround to solve this. Maybe by unloading the NFOP assembly and reloading it? Can anyone help in this, please?
5
2875
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 but this is probabally a reflection of my not clear understanding of the mechanics behind what i'm trying to achieve. Please bear with it I really could do with your help. I have a simple windows form. There are two controls on the form that I...
2
3324
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 CurrentChanged event of the BindingSource of the combobox to update the textbox. When selecting an item in the combobox or when selecting a row in the grid, it is updating the textbox correctly. The problem is when I apply a filter in the grid, and then...
0
10392
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10403
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.