Uppercase in Combobox text

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lakshmi

    Uppercase in Combobox text

    Hi,

    How can I make the combo box text uppercase? For instance when the user
    types in letters in the combobox, I want them to appear as upper case.

    Thanks.

    Lakshmi


  • John B

    #2
    Re: Uppercase in Combobox text

    Lakshmi wrote:
    Hi,
    >
    How can I make the combo box text uppercase? For instance when the user
    types in letters in the combobox, I want them to appear as upper case.
    >
    Thanks.
    >
    Lakshmi
    >
    >
    You could trap them manually in the textchanged event (bearing in mind
    that the text might have changed because an item was selected).

    JB

    Comment

    • Nand Kishore Gupta

      #3
      RE: Uppercase in Combobox text

      Use the following code in the keypress event of the combo box to convert the
      letters to upper case:

      string str = e.KeyChar.ToStr ing().ToUpper() ;
      char[] ch = str.ToCharArray ();
      e.KeyChar = ch[0];

      --
      Nand Kishore Gupta, Bangalore


      "Lakshmi" wrote:
      Hi,
      >
      How can I make the combo box text uppercase? For instance when the user
      types in letters in the combobox, I want them to appear as upper case.
      >
      Thanks.
      >
      Lakshmi
      >
      >
      >

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Uppercase in Combobox text

        Laskhmi,

        This you can do in the same way as the thousands of numeric textboxes and
        autocompletebox es samples are done on internet.

        Be aware not to use the keypress but the keyup event. The later gives
        information about the key that has been pressed.

        For the rest it is just MyPressedcharst ring.ToUpper

        I hope this helps,

        Cor

        "Lakshmi" <lakshmi.vasude van@ayrdata.com .auschreef in bericht
        news:%23R6G3P52 GHA.1796@TK2MSF TNGP06.phx.gbl. ..
        Hi,
        >
        How can I make the combo box text uppercase? For instance when the user
        types in letters in the combobox, I want them to appear as upper case.
        >
        Thanks.
        >
        Lakshmi
        >

        Comment

        • Claes Bergefall

          #5
          Re: Uppercase in Combobox text

          Do you want the items in the list to also be uppercase? If so, a simple
          override will do the trick:

          class UppercaseComboB ox : ComboBox
          {
          private const int CBS_UPPERCASE = 0x2000;
          protected override CreateParams CreateParams
          {
          get
          {
          CreateParams p = base.CreatePara ms;
          p.Style |= CBS_UPPERCASE;
          return p;
          }
          }
          }

          /claes

          "Lakshmi" <lakshmi.vasude van@ayrdata.com .auwrote in message
          news:%23R6G3P52 GHA.1796@TK2MSF TNGP06.phx.gbl. ..
          Hi,
          >
          How can I make the combo box text uppercase? For instance when the user
          types in letters in the combobox, I want them to appear as upper case.
          >
          Thanks.
          >
          Lakshmi
          >

          Comment

          • QuangNhat
            New Member
            • Apr 2012
            • 4

            #6
            I try this and good

            private void cboOperationCod e_KeyPress(obje ct sender, KeyPressEventAr gs e)
            {
            if (e.KeyChar >= 'a' && e.KeyChar <= 'z')
            e.KeyChar = Convert.ToChar( e.KeyChar.ToStr ing().ToUpper() );
            }
            Last edited by Niheel; Apr 30 '12, 10:10 AM. Reason: your solution was posted, future reference this is closed for reply

            Comment

            Working...