Board index » delphi » Uppercase Letters in DBGrid

Uppercase Letters in DBGrid

Hello All !

I need help !

How do you make it so that whatever text a user enters in a DBGrid is in
uppercase ? I tried looking for a CharCase property in the TDBGrid component
and couldn't find one. So how do I do it ?

Thanks in Advance,

Pascal Chong
Singapore

 

Re:Uppercase Letters in DBGrid


Try the OnKeyPress-Event and change the key to the Upcase-Char.

--
Andreas Klein
Remove XXX from my eMail

someone schrieb in Nachricht <3580d89...@news.smartnet.com.sg>...

Quote
>Hello All !

>I need help !

>How do you make it so that whatever text a user enters in a DBGrid is in
>uppercase ? I tried looking for a CharCase property in the TDBGrid
component
>and couldn't find one. So how do I do it ?

>Thanks in Advance,

>Pascal Chong
>Singapore

Re:Uppercase Letters in DBGrid


Here is what I do, when the customer is editing the grid and I want
whatever they typed to be in uppercase I used the following:

// If the user is editing a colum in the field then convert the text
//to upppercase before leaving the column. "dsrcProducts" is my
// database and the grd is called "dbGridProducts"

// When the products database is in edit mode I do the following.

 If dsrcProducts.State in [dsEdit,dsInsert] then
    dbGridProducts.SelectedField.AsString := UpperCase(
dbGridProducts.SelectedField.AsString );

On Fri, 12 Jun 1998 07:37:16 +0200, "Andreas Klein"

Quote
<XXXa-k...@metronet.de> wrote:
>Try the OnKeyPress-Event and change the key to the Upcase-Char.

>--
>Andreas Klein
>Remove XXX from my eMail

>someone schrieb in Nachricht <3580d89...@news.smartnet.com.sg>...
>>Hello All !

>>I need help !

>>How do you make it so that whatever text a user enters in a DBGrid is in
>>uppercase ? I tried looking for a CharCase property in the TDBGrid
>component
>>and couldn't find one. So how do I do it ?

>>Thanks in Advance,

>>Pascal Chong
>>Singapore

Re:Uppercase Letters in DBGrid


On Thu, 11 Jun 1998 13:58:40 +0800, "someone" <some...@somewhere.com>
wrote:

Quote
>Hello All !

>I need help !

>How do you make it so that whatever text a user enters in a DBGrid is in
>uppercase ? I tried looking for a CharCase property in the TDBGrid component
>and couldn't find one. So how do I do it ?

Use the EditMask property of the underlying TField, i.e. >aaaaaaaaaa
to accept up to 10 alfanumerics (a), each alfa converted to uppercase
(>). Of course, this requires that you enter a picture corresponding
to the field's length.

Happy programming.

Jasper

Re:Uppercase Letters in DBGrid


Thanks Jasper !

Tried your suggestion and it worked (almost) ! Problem is : I may need to
insert symbols like dashes '-' and other stuff. I noticed that when I tried
to do that with the Edit Mask turned on, I can't. Guess it only accepts
alphanumeric characters...

Anyway, the good thing is your suggestion was the closest I ever came to a
solution. I tried the other 2 suggestions made to me and I can't seem to be
able to get them to work .

gpdoyon's suggestion -- well, I don't know where to put that bunch of code!
I tried putting it in the OnKeyPress event, but it kept giving me "Not in
insert or edit mode" errors , and when I put the field in Edit mode, it
would allow me to enter only one character.

As for Andreas' suggestion -- thanks ! I guess my reply to your Primary
Index question was as useful as your reply to my problem. I guess I deserve
it !

Thanks and Regards,
Pascal Chong
Singapore

Quote
Jasper Stil wrote in message <3587717e.9288...@news.euro.net>...
>On Thu, 11 Jun 1998 13:58:40 +0800, "someone" <some...@somewhere.com>
>wrote:

>>Hello All !

>>I need help !

>>How do you make it so that whatever text a user enters in a DBGrid is in
>>uppercase ? I tried looking for a CharCase property in the TDBGrid
component
>>and couldn't find one. So how do I do it ?

>Use the EditMask property of the underlying TField, i.e. >aaaaaaaaaa
>to accept up to 10 alfanumerics (a), each alfa converted to uppercase
>(>). Of course, this requires that you enter a picture corresponding
>to the field's length.

>Happy programming.

>Jasper

Re:Uppercase Letters in DBGrid


Quote
In article <3587717e.9288...@news.euro.net>, Jasper Stil (dirks...@euronet.nl) writes:
>On Thu, 11 Jun 1998 13:58:40 +0800, "someone" <some...@somewhere.com>
>wrote:

>>Hello All !

>>I need help !

How about the OnKeyPress event?  Just add something like:
  Key := UpCase(Key);
Quote

>>How do you make it so that whatever text a user enters in a DBGrid is in
>>uppercase ? I tried looking for a CharCase property in the TDBGrid component
>>and couldn't find one. So how do I do it ?

>Use the EditMask property of the underlying TField, i.e. >aaaaaaaaaa
>to accept up to 10 alfanumerics (a), each alfa converted to uppercase
>(>). Of course, this requires that you enter a picture corresponding
>to the field's length.

Re:Uppercase Letters in DBGrid


On Sat, 13 Jun 1998 15:30:21 +0800, "someone" <some...@somewhere.com>
wrote:

Quote
>Tried your suggestion and it worked (almost) ! Problem is : I may need to
>insert symbols like dashes '-' and other stuff. I noticed that when I tried
>to do that with the Edit Mask turned on, I can't. Guess it only accepts
>alphanumeric characters...

Yes, that's because of the 'a's. Change it to 'c' to accept any
character, or 'l' to accept only alfas. Uppercases to *require* input.

Examples:
'>aaaaa;0; ': accept up to 5 alfanumerics converted to uppercase
'>LLLLL;0; ': requires 5 alfas converted to uppercase
'<CCCCC;0; ': requires 5 chars converted to lowercase (<);
'>LL<CCCC<>ccccc;0; ': requires 2 alfas (converted to uppercase),
followed by 4 required chars (converted to lowercase), then permits up
to 5 chars (case as entered);
etc...

The 0 (zero) after the first semicolon is for 'do not save literal
chars' (there are none in the examples anyway) and notice the final
space after the second semicolon, which is to avoid a marker as long
as the picture (default underscore).

For all other possibilities (numerics only, signed numerics, required
or permitted etc...), search for EditMask in the help-files.

Happy programming!

Jasper

Other Threads