I would like to have the characters in a combo box converted to upper case as the user types them. So for instance, when a user types 'a' in the text area, it would be converted to 'A'.
I've tried:
private void cmbList_KeyDown(object sender, KeyEventArgs e)
{
cmbList.Text.ToUpper();
}
Also, is there a way to have the drop down list 'drop' when any character is entered in the text area?
Loading
Mike GoldPosted Aug 26, 2010, 9:34 PM
using System;
using System.Windows.Forms;
namespace ComboBoxUpperCase
{
public partial class UpperComboBox : ComboBox
{
public UpperComboBox()
{
InitializeComponent();
}
protected override void OnLostFocus(EventArgs e)
{
DroppedDown = false;
base.OnLostFocus(e);
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
e.KeyChar = e.KeyChar.ToString().ToUpper()[0];
DroppedDown = true;
base.OnKeyPress(e);
}
}
}