Page 1 of 2

How to limit de lenght of edited text in a Grid.

Posted: Fri Feb 03, 2017 12:05 am
by trmpluym
When using a grid i use:

ColumnControls {aControlDef1,aControlDef2,...aControlDefN}

For a text TEXTBOX

{ cControlType , cDataType , cInputMask , cFormat }

cControlType = 'TEXTBOX' (Required)
cDataType = 'CHARACTER' , 'NUMERIC' , 'DATE' (Required)
cInputMask = cInputMask (Optional)
cFormat = cFormat (Optional)

For example I can use:

{'TEXTBOX','CHARACTER','AAAAAA'}

Now the length edited text is limited to 5 positions but i cannot enter numbers.

{'TEXTBOX','CHARACTER','!!!!!!'}

Now the length edited text is limited to 5 positions, i can enter numbers but all lower case characters are converted to uppercase.

I need something like the old 'X' picture string in Clipper

{'TEXTBOX','CHARACTER','XXXXXX'}

http://www.itlnet.net/programming/progr ... aee8c.html

Like the 'A' inputmask but including numbers.

Or is there another way to limit the lenght of the typed text (like MAXLENGTH in a TEXTBOX)

Or is there another way to do this ?

Theo

How to limit de lenght of edited text in a Grid.

Posted: Fri Feb 03, 2017 9:40 am
by Pablo César
Yes Theo, I think you are right.

It would be nice to have this extra property in the TextBox as optional too.

By this logic:

1. You need to accept alpha and numbers what you would define as character type.
2. Then it can not contain any mask. It has to be free.
3. It remains to limit the typing field. For what would be missing the clause: MAXLENGTH

It would have to be implemented in the _HMG_PARSEGRIDCONTROLS and _HMG_GRIDINPLACEEDIT functions at EDITCONTROLS and CI located at h_grid.prg file.

I believe one difficulty is to avoid when Inputmask and Maxlength clauses.
It can't be used simultaneously. (TextBox/HMGDoc) :|

Remarks:
  1. trmpluym wrote: Fri Feb 03, 2017 12:05 am {'TEXTBOX','CHARACTER','AAAAAA'}

    Now the length edited text is limited to 5 positions but i cannot enter numbers.

    {'TEXTBOX','CHARACTER','!!!!!!'}

    Now the length edited text is limited to 5 positions

    ...

    {'TEXTBOX','CHARACTER','XXXXXX'}
    You want to say 6 positions instead of 5.
     
  2. trmpluym wrote: Fri Feb 03, 2017 12:05 amI need something like the old 'X' picture string in Clipper
    I think it can not be "X" because it deals with the numeric type (according to instructions):
     
    "X"    =     N   =>    Displays DB after negative numbers
 
IMHO, this your message/topic could be moved to  HMG Wishlist  as your request and proposal to implementation.

How to limit de lenght of edited text in a Grid.

Posted: Fri Feb 03, 2017 10:40 am
by Pablo César
Hello Theo, I've been able to do what you need.
To let us for adding one more parameter (optional) to the TextBox in the Grid for MAXLENGTH) :D

Change in source h_grid.prg is required as I said earlier. It is up to the HMG development team to approve or not to become a permanent part of HMG in the future.

The change does not imply any change with the operation of the TextBox in the Grid and maintains the backward compatibility.
The only limitation that Inputmask and Maxlength is not be placed simultaneously. In the implemented code, there is no verification on this issue. The programmer has to keep that in mind, otherwise MAXLENGTH simply will not work.

Here's the source file to replace and rebuild the library through BuildLib32.bat:
 
h_grid.rar
HMG source code (Modified)
(17.21 KiB) Downloaded 223 times
 
The usage syntax is:     {'TEXTBOX','CHARACTER',,,5}

Hereunder a SAMPLES Demo:

Code: Select all

#include "hmg.ch"

Function Main

OpenTables()

    DEFINE WINDOW Win_1 ;
        AT 0,0 ;
        WIDTH 640 HEIGHT 480 ;
        TITLE 'Tutor 20: GRID Test' ;
        MAIN NOMAXIMIZE 

        DEFINE MAIN MENU 
            POPUP 'File'
                ITEM 'Set Grid RecNo' ACTION Win_1.Grid_1.Value := Val ( InputBox ('Set Grid RecNo','') )
                ITEM 'Get Grid RecNo' ACTION MsgInfo ( Str ( Win_1.Grid_1.RecNo ) )
                SEPARATOR
                ITEM 'Exit' ACTION Win_1.Release
            END POPUP
            POPUP 'Help'
                ITEM 'About' ACTION MsgInfo ("Tutor 20: GRID Test") 
            END POPUP
        END MENU

        @ 10,10 GRID Grid_1 ;
            WIDTH 610 ;
            HEIGHT 390 ; 
            HEADERS { 'Code' , 'First Name' , 'Last Name', 'Birth Date', 'Married' , 'Biography' } ;
            WIDTHS { 150 , 150 , 150 , 150 , 150 , 150 } ;
            ROWSOURCE "Test" ;
            COLUMNFIELDS { 'Code' , 'First' , 'Last' , 'Birth' , 'Married' , 'Bio' } ;
            COLUMNCONTROLS {{'TEXTBOX','NUMERIC','999'},{'TEXTBOX','CHARACTER',,,5},{'TEXTBOX','CHARACTER',,,5},{'TEXTBOX','DATE'},{'CHECKBOX'},{'TEXTBOX','CHARACTER'}};
            ALLOWDELETE ;
            EDIT

    END WINDOW

    CENTER WINDOW Win_1

    ACTIVATE WINDOW Win_1

Return Nil

Procedure OpenTables()
    Use Test
//    Win_1.Grid_1.RecNo := RecNo() 
Return Nil
The fifth parameter is optional and is the value in number of characters that will be accepted as is done in the MAXLENGTH property of the normal TextBox.

I hope the change is satisfactory and can be enjoyed by all on a permanent basis.

@ Claudio. All changes I've made are identified with: // Pablo on February, 2017

How to limit de lenght of edited text in a Grid.

Posted: Fri Feb 03, 2017 1:21 pm
by Pablo César
your request and proposal to implementation
+1 :)

IMHO, this your message/topic could be moved to  HMG Wishlist  as your request and proposal to implementation.
Please Theo, kindly ask to Rathinagiri to move the topic. Its more appropriated.

Re: How to limit de lenght of edited text in a Grid.

Posted: Fri Feb 03, 2017 2:28 pm
by srvet_claudio
Thanks

How to limit de lenght of edited text in a Grid.

Posted: Fri Feb 03, 2017 6:25 pm
by Pablo César
Claudio, aqui en adjunto una pequeña alteracion agregando esa nueva propiedad en el Grid y con ejemplo para el HMGDoc.

<DOC file was removed because typo were found and been corrected at message ahead of this topic.>

Re: How to limit de lenght of edited text in a Grid.

Posted: Fri Feb 03, 2017 9:29 pm
by trmpluym
Wow Pablo !!

Amazing, this is exactly what i needed :D

You made my day.

Many thanks my friend !

Theo

Re: How to limit de lenght of edited text in a Grid.

Posted: Fri Feb 03, 2017 10:15 pm
by Pablo César
You are welcome :)

Re: How to limit de lenght of edited text in a Grid.

Posted: Fri Feb 03, 2017 10:31 pm
by srvet_claudio
Thanks

Re: How to limit de lenght of edited text in a Grid.

Posted: Sat Feb 04, 2017 10:45 am
by serge_girard
Great Pablo ! Thanks!

One detail: nMaxLenght should be nMaxLength

Serge