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

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

trmpluym
Posts: 242
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 6 times
Been thanked: 21 times

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

Post by trmpluym » Fri Feb 03, 2017 12:05 am

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

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri Feb 03, 2017 9:40 am

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 am
    I 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.
Last edited by Pablo César on Fri Feb 03, 2017 10:40 am, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri Feb 03, 2017 10:40 am

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 74 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
Last edited by Pablo César on Fri Feb 03, 2017 2:29 pm, edited 9 times in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri Feb 03, 2017 1:21 pm

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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Post by srvet_claudio » Fri Feb 03, 2017 2:28 pm

Thanks
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri Feb 03, 2017 6:25 pm

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.>
Last edited by Pablo César on Sat Feb 04, 2017 11:58 am, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

trmpluym
Posts: 242
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 6 times
Been thanked: 21 times

Post by trmpluym » Fri Feb 03, 2017 9:29 pm

Wow Pablo !!

Amazing, this is exactly what i needed :D

You made my day.

Many thanks my friend !

Theo

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri Feb 03, 2017 10:15 pm

You are welcome :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Post by srvet_claudio » Fri Feb 03, 2017 10:31 pm

Thanks
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
serge_girard
Posts: 2283
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 544 times
Been thanked: 115 times
Contact:

Post by serge_girard » Sat Feb 04, 2017 10:45 am

Great Pablo ! Thanks!

One detail: nMaxLenght should be nMaxLength

Serge

Post Reply