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

Force Upper in C#

How do you make a ComboBox force casing to uppercase? With a TextBox, I do
this:
TextBox txtName;
this.txtName.CharacterCasing = CharacterCasing.Upper;

And it makes whatever the user types appear in upper case, which is what I
want. But with a ComboBox, if I do this:

ComboBox TCombo;
this.TCombo.CharacterCasing = CharacterCasing.Upper;

It fails, because CharacterCasing is not a member of the ComboBox class. How
should this be done? Thanks.

Nov 17 '05 #1
2 7027
Richard,

In order to do this, you will have to subclass the ComboBox, or handle
the appropriate events to cause the change in behavior that you want. I
think the easier way is to create a custom ComboBox where you override the
OnKeyDown and OnKeyUp (and maybe the OnKeyPress) methods and alter the
KeyEventArgs instance passed in to represent an upper-case character being
typed. I'm not positive it will work. If it doesn't, then you will
probably have to override the WndProc method and handle the appropriate
windows messages that handle key events, and modify them so that they
represent an upper case character.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Richard MSL" <Ri*************@nospam.nospam> wrote in message
news:9B**********************************@microsof t.com...
How do you make a ComboBox force casing to uppercase? With a TextBox, I do
this:
TextBox txtName;
this.txtName.CharacterCasing = CharacterCasing.Upper;

And it makes whatever the user types appear in upper case, which is what I
want. But with a ComboBox, if I do this:

ComboBox TCombo;
this.TCombo.CharacterCasing = CharacterCasing.Upper;

It fails, because CharacterCasing is not a member of the ComboBox class.
How
should this be done? Thanks.

Nov 17 '05 #2
if you add items to the combobox do:

myCombo.Items.Add(myString.ToUpper());

"Richard MSL" <Ri*************@nospam.nospam> schrieb im Newsbeitrag
news:9B**********************************@microsof t.com...
How do you make a ComboBox force casing to uppercase? With a TextBox, I do
this:
TextBox txtName;
this.txtName.CharacterCasing = CharacterCasing.Upper;

And it makes whatever the user types appear in upper case, which is what I
want. But with a ComboBox, if I do this:

ComboBox TCombo;
this.TCombo.CharacterCasing = CharacterCasing.Upper;

It fails, because CharacterCasing is not a member of the ComboBox class. How should this be done? Thanks.

Nov 17 '05 #3

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

Similar topics

14
by: Simon Wigzell | last post by:
I want to display HTML text inside a div and have the page open scrolled to the bottom. (My div has overflow:auto so that it appears with scroll bars) I have found this that works on a textarea:...
8
by: MLH | last post by:
I have a textbox on a form into which an alpha-numeric string of data is entered. I wish to force the casual user, who would sometimes use upper case, sometimes not and sometimes MIX the case -...
3
by: Steve | last post by:
I want to force a window to scroll and am finding this to be an impossibly difficult task. First I tried using the API functions ScrollWindow and ScrollWindowEx but they do not work. The portion...
7
by: OHM | last post by:
Hi Guys, I wouldnt normally ask for help on this but Im really strapped for time. Does anyone know how I can force characters in a DataGrid cell to uppercase as they are typed. Cheers - OHM
0
by: comp.lang.php | last post by:
I have a form that when you click the "Generate Report" submit button, it will force download a CSV file, required for this project. On the very same page you also have a "Search" submit button,...
5
by: bob | last post by:
Now this ought to be a simple matter. But nothing's simple in the Net world, I'm finding. In vb6 you could use "!" to force text to upper case in the format function. I've searched the vb.net...
3
by: bob | last post by:
In vb6 you could say s = Format(s, "!") to force text to upper case in the format function. I've searched the vb.net help system and can't find any help on formatting text. There's plenty of help...
5
by: =?Utf-8?B?cmtibmFpcg==?= | last post by:
How can I force the users to enter characters in uppercase? I want to do this in a TextBox control of an aspx page. Then I want the same to be moved to inside a GridView control. Thanks.
10
by: Daniel | last post by:
how to force a .net application to use .net 2.0 ? this windows service is about 4 years old and im pretty sure is using .net 1.x runtime. Is there soem setting in the installer that says to use...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
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?

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.