473,950 Members | 19,838 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#: ComboBox Problem

Hi, I have a comboBox set to also be editable. If I have code that is
something like:

cmbBox.Text = "Hello";
MessageBox.Show (cmbBox.Text);

The MessageBox will display just an empty string. I cannot figure this out.
The text "Hello" will be displayed in the combobox but it doesn't seem to
store the text. If I edit the box at runtime then it does store it correctly.

This is very important. It is the last bug I need to fix in my Project to
graduate, in which I am working with the Rolla Police Department. Thanks.
Nov 17 '05 #1
4 8460
Hi Tony,

I am unable to reproduce your bug, and for me the MessageBox will display "Hello".

Can you show us a small but complete code sample demonstrating the problem?

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #2
Let me give more information first. As to getting a small code demonstration
that might be difficult as this is a very large program.

The ComboBox is bound to a DataTable which is what I believe is causing the
problem. I want the user to be able to select from the list or type in their
own copy and this part works.

When the program reads from the Database and does something similar to
cmbBox.Text = temp.ToString() where temp is a value from the database which
is not a member of the list, then it doesn't seem to accept it. If the user
say then retypes the same thing it will.

Hopefully that clears it up a little.

"Morten Wennevik" wrote:
Hi Tony,

I am unable to reproduce your bug, and for me the MessageBox will display "Hello".

Can you show us a small but complete code sample demonstrating the problem?

--
Happy coding!
Morten Wennevik [C# MVP]

Nov 17 '05 #3
I was able to get it to work. It seems that when the comboBox is bound to a
datasource, cmbBox.Text="te xt" will only work if "text" is one of the options
from the datasource. It will put "text" in the box, but doesn't save it in
the Text Property.

So what I had to do was add a new row to the DataView which was bound to the
ComboBox which had the same text that I read from the database. This was only
temporary and wasn't saved back to the database.

Thanks for the help.

Tony

"tonyblum" wrote:
Let me give more information first. As to getting a small code demonstration
that might be difficult as this is a very large program.

The ComboBox is bound to a DataTable which is what I believe is causing the
problem. I want the user to be able to select from the list or type in their
own copy and this part works.

When the program reads from the Database and does something similar to
cmbBox.Text = temp.ToString() where temp is a value from the database which
is not a member of the list, then it doesn't seem to accept it. If the user
say then retypes the same thing it will.

Hopefully that clears it up a little.

"Morten Wennevik" wrote:
Hi Tony,

I am unable to reproduce your bug, and for me the MessageBox will display "Hello".

Can you show us a small but complete code sample demonstrating the problem?

--
Happy coding!
Morten Wennevik [C# MVP]

Nov 17 '05 #4
Thank you for reporting the solution :)
On Wed, 27 Apr 2005 03:16:02 +0200, tonyblum <to******@discu ssions.microsof t.com> wrote:
I was able to get it to work. It seems that when the comboBox is bound to a
datasource, cmbBox.Text="te xt" will only work if "text" is one of the options
from the datasource. It will put "text" in the box, but doesn't save it in
the Text Property.

So what I had to do was add a new row to the DataView which was bound to the
ComboBox which had the same text that I read from the database. This was only
temporary and wasn't saved back to the database.

Thanks for the help.

Tony

"tonyblum" wrote:
Let me give more information first. As to getting a small code demonstration
that might be difficult as this is a very large program.

The ComboBox is bound to a DataTable which is what I believe is causing the
problem. I want the user to be able to select from the list or type in their
own copy and this part works.

When the program reads from the Database and does something similar to
cmbBox.Text = temp.ToString() where temp is a value from the database which
is not a member of the list, then it doesn't seem to accept it. If the user
say then retypes the same thing it will.

Hopefully that clears it up a little.

"Morten Wennevik" wrote:
> Hi Tony,
>
> I am unable to reproduce your bug, and for me the MessageBox will display "Hello".
>
> Can you show us a small but complete code sample demonstrating the problem?
>
> --
> Happy coding!
> Morten Wennevik [C# MVP]
>


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2509
by: Chandra | last post by:
Hello Sir, This is Chandra and Working as Software Engineer. I got a really weird problem with ComboBoxes. I have set the ComboBox DroppedDown Property to true. Now the actual problem is When the ComboBox DroppedDown is Shown I have to actually click twice to get out of the form or need to click twice to do anything.
7
8564
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way of doing it. I have a table with products, tblProducts, some of them are Active while others are Inactive. The form shows all the products purchased by a customer, both Active and Inactive in a ComboBox, cbProducts. My client wants to view all...
8
12131
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
1
2506
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new DataTable("table"); testTable.Columns.Add("Col1", typeof(Int32)); testTable.Columns.Add("Col2", typeof(String)); testTable.Rows.Add(testTable.NewRow());
3
6845
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article: http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx I have a problem when there are two DataGrid's on one form, and when I switch focus from one grid to the other. To be more precise, when I'm editing a combo box column in one grid, and then click in the combo column of...
0
2394
by: tupolev | last post by:
Hi, I already post this item but now I know whats wrong: I want to allow the user to edit the items in a combobox. The problem is that the textchange event works just one time (for the first changed letter) because he reset the selectedindex of the combobox to -1. In debug mode I can't see where he does this. How can I solve this? My code sofar: contactlijst is a structure and the volgnummer is the index of the item in the combobox
4
4029
by: Keith | last post by:
Hello - this started out as a minor annoyance - and now is starting to bother me more and more - I'm hoping someone can help me. I would like to have a combobox display - NOT initially be blank - but contain a value. However the value is just for user reference - not really one of the combobox choices. For example intially the combobox should equal the word Select - and the item values can be say 'one', 'two', and 'three'.
30
4637
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a corresponding field in the lookup table. In my data table we store the ID in what I will call the 'key' field. == Description of the desired operation:
4
4634
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
5
3202
by: Peter M. | last post by:
I'm struggling with combobox databinding with something I consider a bug... I'm binding my combobox to an array of structs. The struct exposes two public properties, ID and Name, to be used as the value and displaymember properties. This works fine. My combobox contains the correct data. However I'm also binding my SelectedValue property to a column in a datatable. Here's where I'm lost. The combobox doesn't show the correct
0
10171
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11600
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11191
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
11369
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
10703
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
6233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6352
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3558
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.