473,382 Members | 1,409 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,382 software developers and data experts.

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 8439
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="text" 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******@discussions.microsoft.com> wrote:
I was able to get it to work. It seems that when the comboBox is bound to a
datasource, cmbBox.Text="text" 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
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...
7
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...
8
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...
1
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...
3
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:...
0
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...
4
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...
30
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...
4
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...
5
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.