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

Character Casing in Combo

How to make a ComboBox to display characters only in Upper or Lower Case as
you type?

I was trying to override OnKeyDown and OnKeyPress but coudn't figure it
out. The problem is that in OnKeyPress
new key value is not writed in the Combo.Text until the event is executed.
Nov 16 '05 #1
3 3079
Hi UmmagummA,

What you do in the KeyPressEvent is set e.Handled = true to prevent the
characters ever reaching the ComboBox. Instead add a character of your
own.

Something like this might work for you, given a ComboBox b and its
KeyPressEvent b_Press

private void b_Press(object sender, KeyPressEventArgs e)
{
if(Char.IsLetter(e.KeyChar))
{
e.Handled = true;
string s = e.KeyChar.ToString();
b.Text += s.ToUpper();
b.SelectionStart = b.Text.Length;
}
}
--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
Even better, using Char.ToUpper

if(Char.IsLetter(e.KeyChar))
{
e.Handled = true;
b.Text += Char.ToUpper(e.KeyChar);
b.SelectionStart = b.Text.Length;
}
--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
Huge Thanks!

When I saw it, I tought, why I didn't think of it :))
Nov 16 '05 #4

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

Similar topics

2
by: deko | last post by:
I'm trying to use a textbox to search and display records as each letter is typed in - similar to the behavior of a combo box. But for some reason I can't seem to get the wildcard search character...
3
by: ILCSP | last post by:
Heello, I'm using Access 2000. I have a form with a combo box that has a query as its row source and it's bound to column 1. This combo box is unbound to a record like the rest of the form...
4
by: Shabs | last post by:
Hi, We are having this problem here on our project where we store all firstnames, lastnames in the oracle database in uppercase, when we retrieve the data to be used in web application and...
2
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! Is it possible to enable Charater Casing in a ComboBox, if, how? As of now i am using KeyUp event to make sure that the char entered is Uppercase. Regards Martin Arvidsson
3
by: hmiller | last post by:
Hey everyone, I am having a hell of a time trying to set this menu system up. Here's what I'm trying to do. Combo Box One; is populated by names under properties "row source" "Phase 1"...
5
by: Kay | last post by:
Hi All, I'm trying to write a small sub/function to replace some (invalid) character in a combo box, or may be even text box. For example, I have several combo boxes that allows user to select...
3
by: =?Utf-8?B?TWlrZSBPS0M=?= | last post by:
The text in my combo box is longer than the control can show, when I click on the down arrow, I can see the whole text, but when I select one of the items, the text box of the combo box shows the...
2
by: =?Utf-8?B?R3dlblA=?= | last post by:
Hi there Anyone know the syntax in ASP that shows 2 values in a drop down combo with a tab between them I have tried: <option value=<%= rstT.fields("pcode")%>><%= rstT.fields("pcode") &...
0
by: Dr. Colombes | last post by:
I've used a very nice Keystroke Logger Python shareware program (EVDEV.py), written by Micah Dowty. But I couldn't find a dedicated ASCII Character Logger program. Does anyone know of an ASCII...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
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,...

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.