Something like combosearchbox, but in a grid control

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
jparada
Posts: 291
Joined: Fri Jan 23, 2009 5:18 pm
Been thanked: 4 times

Something like combosearchbox, but in a grid control

Post by jparada » Wed Apr 21, 2010 5:32 pm

Hi,

I'm trying to do a search in a grid control and textbox control (QuickSearch example by Esgici).

But I'd like to Writing to the textbox control, grid control gets the focus (as well as in the example Combosearchbox).

I already have taken a look at Combosearchbox source code, and I saw that this "trick" is done by the following line:

Code: Select all

SetProperty (ThisWindow.Name, "_csList", "VALUE", 1)
But if I do something similar in the Grid control does not work, and I do not know how to do this.

Someone could please give me an idea of how to implement this. and of course I would do the same, as does the combosearchbox control, also use up and down key.

I appreciate any help or advice you can show me about this implementation.

Thanks

Best Regards
Javier
Attachments
img.png
img.png (14.91 KiB) Viewed 2387 times

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Been thanked: 1 time
Contact:

Post by l3whmg » Wed Apr 21, 2010 9:06 pm

Hi Jparada,
I'm not a guru but I give you my simple solution. First of all I think you want use two control and for this reason it's to hard give a clear solution like Combo. Any way this is my code:

Code: Select all

#include "hmg.ch"


FUNCTION main( ... )
p000_Main()
RETURN NIL

/****************************************************************
* main entry
****************************************************************/
STATIC FUNCTION p000_Main()

p000_Define()

ACTIVATE WINDOW ALL
RETURN NIL

/****************************************************************
* form definition
****************************************************************/
STATIC FUNCTION p000_Define()
LOCAL aRows := {}
AADD(aRows, {"CODE_01","John"})
AADD(aRows, {"CODE_02","William"})
AADD(aRows, {"CODE_03","Lisa"})
AADD(aRows, {"CODE_04","Fernandez"})
AADD(aRows, {"CODE_05","Luigi"})

SET NAVIGATION EXTENDED
DEFINE WINDOW p000win ;
 ROW 0 ;
 COL 0 ;
 WIDTH 940 ;
 HEIGHT 705 ;
 TITLE "Main form" ;
 WINDOWTYPE MAIN ;
 ICON 'L3W_ICO' ;
 ON INIT p000_Init() ;
 FONTNAME "Arial" FONTSIZE 10

 DEFINE MAIN MENU
  DEFINE POPUP '&File'
   MENUITEM 'e&Xit' ACTION p000_exit()
  END POPUP
 END MENU

 DEFINE TEXTBOX fldsearch
  ROW 420
  COL 125
  HEIGHT 25
  WIDTH 300
  TOOLTIP 'Testo da cercare'
  MAXLENGTH 100
  ONCHANGE p000_Find()
 END TEXTBOX

 DEFINE GRID Grid1
  PARENT p000win
  ROW 60
  COL 20
  WIDTH 600
  HEIGHT 330
  HEADERS {'Code','Description'}
  WIDTHS {100,250}
  ITEMS aRows
 END GRID

END WINDOW
p000win.Center
RETURN NIL

/****************************************************************
* Init function
****************************************************************/
STATIC FUNCTION p000_Init()
RETURN NIL

/****************************************************************
* exit function
****************************************************************/
STATIC FUNCTION p000_Exit()
ReleaseAllWindows()
RETURN NIL

/****************************************************************
* finder function
****************************************************************/
STATIC FUNCTION p000_Find()
LOCAL nX := 0, aTemp := {}, nGrid := 0, cFind := ALLTRIM(p000win.fldsearch.Value)
FOR nX := 1 TO p000win.Grid1.ItemCount
 aTemp := p000win.Grid1.Item(nX)
 IF AT(cFind, aTemp[1])<>0 .OR. ;
  AT(cFind, aTemp[2])<>0
  nGrid := nX
  EXIT
 ENDIF
NEXT nX
IF nGrid<>0
 p000win.Grid1.Value := nGrid
ENDIF
RETURN NIL
I hope I've understand your request :roll:
Best regards
Luigi from Italy
www.L3W.it

jparada
Posts: 291
Joined: Fri Jan 23, 2009 5:18 pm
Been thanked: 4 times

Post by jparada » Wed Apr 21, 2010 10:51 pm

Hi Luigi,

Thanks for answering, but I think your example is very similar to the example I said (by Esgici), and does not work the way I like to implement.

I would like the Browse control, get the focus (selected cell, blue color), while you type something in textbox control.

Just like the example ComboSearchBox.

Thanks

Best Regards
Javier

User avatar
Rathinagiri
Posts: 5268
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 171 times
Been thanked: 174 times
Contact:

Post by Rathinagiri » Thu Apr 22, 2010 6:41 am

ComboSearchBox is an implementation which creates a new MODAL window (with no title etc.,) just over the textbox along with a textbox and a listbox beneath.

The user doesn't feel that, a new window is opened and released. This is what Roberto does in in-place cell editing of grid.

If you see the source code of combosearchbox, especially from line no. 167

Code: Select all

ON KEY UP     OF This.Window ACTION _CSDoUpKey()  
ON KEY DOWN   OF This.Window ACTION _CSDoDownKey()
ON KEY ESCAPE OF This.Window ACTION _CSDoEscKey(cParentName, cCSBoxName) 
Up/Down/Escape keys of the MODAL window are captured and processed. The focus doesn't move to LISTBOX at all. It is just a trick. Whenever you press up key, listbox value is decreased and whenever you press the down key, the listbox value is increased. If you press escape, modal window is released.

If you want to use grid in the place of listbox, yes it can be done by just changing the combosearchbox source.

If you want further clarification don't hesitate to ask.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

jparada
Posts: 291
Joined: Fri Jan 23, 2009 5:18 pm
Been thanked: 4 times

Post by jparada » Thu Apr 22, 2010 7:55 pm

Hi,
ComboSearchBox is an implementation which creates a new MODAL window (with no title etc.,) just over the textbox along with a textbox and a listbox beneath.

The user doesn't feel that, a new window is opened and released. This is what Roberto does in in-place cell editing of grid.

If you see the source code of combosearchbox, especially from line no. 167

Code: Select all

ON KEY UP     OF This.Window ACTION _CSDoUpKey()  
ON KEY DOWN   OF This.Window ACTION _CSDoDownKey()
ON KEY ESCAPE OF This.Window ACTION _CSDoEscKey(cParentName, cCSBoxName)

Up/Down/Escape keys of the MODAL window are captured and processed. The focus doesn't move to LISTBOX at all. It is just a trick. Whenever you press up key, listbox value is decreased and whenever you press the down key, the listbox value is increased. If you press escape, modal window is released.
This I already knew it, I have already taken a look at the source code and I know it is a "trick" with a modal window.

What I do not know is how to achieve that while writing to the textbox control "apparently" the focus (highlighted item) is placed on the element that matches in the listbox control.

The only thing I've seen, is that apparently, this line:

Code: Select all

SetProperty (ThisWindow.Name, "_csList", "VALUE", 1)
Does the trick, but... I'm not sure about it.

But doing something like that does not work with the Browse control (in my case, so far I do not use the Grid control).

Maybe someone can provide any help or tip to implement the "trick"

So my specific question, whether it is possible (almost always be around), that while typing in the textbox Grid control gets the focus (entire row selected, in this case blue), and it is possible, my next question is , how to do that.

I appreciate any help.

Thanks.

Best Regards
Javier

User avatar
Rathinagiri
Posts: 5268
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 171 times
Been thanked: 174 times
Contact:

Post by Rathinagiri » Thu Apr 22, 2010 8:25 pm

I will try to create a sample. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

jparada
Posts: 291
Joined: Fri Jan 23, 2009 5:18 pm
Been thanked: 4 times

Post by jparada » Fri Apr 23, 2010 4:08 am

Hi,
I will try to create a sample
It would be great (at least for me) that you or someone else provide an example about this implementation.

I will be waiting for news.

Thanks

Best Regards
Javier

User avatar
Rathinagiri
Posts: 5268
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 171 times
Been thanked: 174 times
Contact:

Post by Rathinagiri » Fri Apr 23, 2010 7:00 am

Here is a new control "ComboSearchGrid".

Code: Select all

#include "hmg.ch"

#command @ <row>, <col> COMBOSEARCHGRID <name>                  ;
             [ <dummy1: OF, PARENT> <parent> ] ;
                            [ HEIGHT <height> ]             ;
                            [ WIDTH <width> ]               ;
                            [ VALUE <value> ]               ;
                            [ FONT <fontname> ]             ;
                            [ SIZE <fontsize> ]             ;
                            [ <bold : BOLD> ] ;
                            [ <italic : ITALIC> ] ;
                            [ <underline : UNDERLINE> ] ;
                            [ TOOLTIP <tooltip> ]           ;
                            [ BACKCOLOR <backcolor> ] ;
                            [ FONTCOLOR <fontcolor> ] ;
                            [ MAXLENGTH <maxlenght> ]       ;
                            [ <upper: UPPERCASE> ]          ;
                            [ <lower: LOWERCASE> ]          ;
                            [ <numeric: NUMERIC> ]          ;
                            [ ON GOTFOCUS <gotfocus> ]      ;
                            [ ON LOSTFOCUS <lostfocus> ]    ;
                            [ ON ENTER <enter> ]      ;
                            [ <RightAlign: RIGHTALIGN> ]   ;
                            [ <notabstop: NOTABSTOP> ]   ;
                            [ HELPID <helpid> ]       ;
                            [ ITEMS <aitems>  ]     ;
                            [ <anywhere :ANYWHERESEARCH> ];
                            [ HEADERS <aheaders>  ]     ;
                            [ WIDTHS <awidths>]  ;
             =>;
             _DefineComboSearchGrid( <"name">, <"parent">, <col>, <row>, <width>, <height>, <value>, ;
                <fontname>, <fontsize>, <tooltip>, <maxlenght>, ;
                            <.upper.>, <.lower.>, <.numeric.>, ;
                <{lostfocus}>, <{gotfocus}>, <{enter}>, ;
                <.RightAlign.>, <helpid>, <.bold.>, <.italic.>, <.underline.>, <backcolor> , <fontcolor> , <.notabstop.>, <aitems>,<.anywhere.> ,<aheaders>,<awidths>)

#xcommand ANYWHERESEARCH	<sort>	;
	=>;
	_HMG_SYSDATA \[ 464 \]		:= <sort>
                
                
                               
#xcommand DEFINE COMBOSEARCHGRID <name>;
       =>;
       _HMG_SYSDATA \[ 416 \]   := <"name">   ;; //name
       _HMG_SYSDATA \[ 417 \]   := Nil      ;; //parent
       _HMG_SYSDATA \[ 431 \]   := Nil      ;; //row
       _HMG_SYSDATA \[ 432 \]   := Nil      ;; //col
       _HMG_SYSDATA \[ 421 \]   := Nil      ;; // height
       _HMG_SYSDATA \[ 420 \]   := Nil      ;; // width
       _HMG_SYSDATA \[ 434 \]   := Nil      ;; //value
       _HMG_SYSDATA \[ 422 \]  := Nil      ;; //font
       _HMG_SYSDATA \[ 423 \]   := Nil      ;; // size
       _HMG_SYSDATA \[ 412 \]   := .f.      ;; //bold
       _HMG_SYSDATA \[ 413 \]   := .f.      ;; // italic
       _HMG_SYSDATA \[ 415 \]   := .f.      ;; // underline
       _HMG_SYSDATA \[ 424 \]   := Nil      ;; //tooltip
       _HMG_SYSDATA \[ 457 \]   := Nil      ;; // backcolor
       _HMG_SYSDATA \[ 458 \]   := Nil      ;; // fontcolor
       _HMG_SYSDATA \[ 442 \] := Nil   ;; // maxlength
       _HMG_SYSDATA \[ 475 \] := .f.      ;; //upper
       _HMG_SYSDATA \[ 476 \]   := .f.      ;;  //lower
       _HMG_SYSDATA \[ 477 \]   := .f.      ;;  // numeric
       _HMG_SYSDATA \[ 426 \] := Nil      ;; // gotfocus
       _HMG_SYSDATA \[ 427 \]   := Nil         ;; //lostfocus
       _HMG_SYSDATA \[ 437 \]   := Nil         ;; //enter
       _HMG_SYSDATA \[ 440 \]    := .f.          ;; //rightalign
       _HMG_SYSDATA \[ 428 \]   := .t.      ;; //tabstop
       _HMG_SYSDATA \[ 429 \]   := Nil      ;; // helpid
       _HMG_SYSDATA \[ 436 \]      := Nil   ;;    // items
       _HMG_SYSDATA \[ 445 \]      := Nil   ;;  // headers
       _HMG_SYSDATA \[ 446 \]      := Nil   ;;  // widths       
       _HMG_SYSDATA \[ 464 \]      := .f.       // anywhere search

         
#xcommand END COMBOSEARCHGRID;
       =>;
          _DefineComboSearchGrid(;
             _HMG_SYSDATA \[ 416 \],; //name
             _HMG_SYSDATA \[ 417 \],; //parent
             _HMG_SYSDATA \[ 432 \],; //col
             _HMG_SYSDATA \[ 431 \],; //row
             _HMG_SYSDATA \[ 420 \],; //width
             _HMG_SYSDATA \[ 421 \],; //height
             _HMG_SYSDATA \[ 434 \],; //value
             _HMG_SYSDATA \[ 422 \],; //fontname
             _HMG_SYSDATA \[ 423 \],; //fontsize
             _HMG_SYSDATA \[ 424 \],; //tooltip
             _HMG_SYSDATA \[ 442 \],; //maxlength
             _HMG_SYSDATA \[ 475 \],; //upper
             _HMG_SYSDATA \[ 476 \],; //lower
             _HMG_SYSDATA \[ 477 \],; //numeric
             _HMG_SYSDATA \[ 427 \],; //lostfocus
             _HMG_SYSDATA \[ 426 \],; //gotfocus
             _HMG_SYSDATA \[ 437 \],; //enter
             _HMG_SYSDATA \[ 440 \],; //rightalign
             _HMG_SYSDATA \[ 429 \],; //helpid
             _HMG_SYSDATA \[ 412 \],; //bold
             _HMG_SYSDATA \[ 413 \] , ; //italic
             _HMG_SYSDATA \[ 415 \],; //underline
             _HMG_SYSDATA \[ 457 \] , ; //backcolor
             _HMG_SYSDATA \[ 458 \] , ;// fontcolor
             _HMG_SYSDATA \[ 428 \] ,; //tabstop
             _HMG_SYSDATA \[ 436 \] ,; // aitems
             _HMG_SYSDATA \[ 464 \], ; //  anywhere search
             _HMG_SYSDATA \[ 445 \], ; // headers
             _HMG_SYSDATA \[ 446 \] ; // widths
             ) 
       



function main
local aArray := {{"Rathinagiri","Sivakasi"},{"Raman","Madurai"},{"Rajan","Chennai"},{"Rajkumar","Delhi"}}

define window x at 0,0 width 500 height 400 main
   define label namelabel
      row 10
      col 10
      width 100
      value "Name"
   end label
   define combosearchgrid names
      row 10
      col 110
      width 300
      items aArray
      headers {"Name","City"}
      widths {200,80} 
   end combosearchgrid
   define button ok
      row 40
      col 10
      width 80
      caption "Ok"
      action msginfo("Just a button")
   end button
end window
x.center
x.activate
return nil




      

PROC _DefineComboSearchGrid( cCSBoxName,; 
                            cCSBoxParent,; 
                            cCSBoxCol,; 
                            cCSBoxRow,; 
                            cCSBoxWidth,; 
                            cCSBoxHeight,; 
                            cCSBoxValue,;
                            cFontName,; 
                            nFontSize,; 
                            cToolTip,; 
                            nMaxLenght,;
                            lUpper,; 
                            lLower,; 
                            lNumeric,;
                            bLostFocus,; 
                            bGotFocus,; 
                            bEnter,;
                            lRightAlign,; 
                            nHelpId,; 
                            lBold,; 
                            lItalic,; 
                            lUnderline,; 
                            aBackColor,; 
                            aFontColor,; 
                            lNoTabStop,; 
                            aArray,;
                            lAnyWhere,;
                            aHeaders,;
                            aWidths )
            
   LOCAL   cParentName := ''
           
   DEFAULT cCSBoxWidth  := 120
   DEFAULT cCSBoxHeight := 24
   DEFAULT cCSBoxValue  := ""
   DEFAULT bGotFocus    := ""
   DEFAULT bLostFocus   := ""
   DEFAULT nMaxLenght   := 255
   DEFAULT lUpper       := .F.
   DEFAULT lLower       := .F.
   DEFAULT lNumeric     := .F.
   DEFAULT bEnter       := ""
   DEFAULT lAnyWhere    := .f.
           
   IF _HMG_SYSDATA [ 264 ] = .T.                  // _HMG_BeginWindowActive
      cParentName := _HMG_SYSDATA [ 223 ]         // _HMG_ActiveFormName 
   ELSE
      cParentName := cCSBoxParent
   ENDIF

   _DefineTextBox( cCSBoxName,;
                   cCSBoxParent,;
                   cCSBoxcol,;
                   cCSBoxRow,;
                   cCSBoxWidth,;
                   cCSBoxheight,;
                   cCSBoxValue,;
                   cFontName,;
                   nFontSize,;
                   cToolTip,;
                   nMaxLenght,;
                   lUpper,;
                   lLower,;
                   lNumeric,;
                   .f.,;
				   bLostFocus,;
				   bGotFocus,;
				   {||CreateCSBoxGrid( cParentName, cCSBoxName, aArray, cCSBoxRow, cCSBoxCol,lAnyWhere,aHeaders,aWidths)},;
				   bEnter,;
				   lRightAlign,;
				   nHelpId,;
				   .f.,;
				   lBold,;
				   lItalic,;
				   lUnderline,;
				   .f.,;
				   ,;
				   aBackColor,;
				   aFontColor,;
				   .f.,;
				   iif(lNoTabStop,.f.,.t.);
				   )
    
RETURN // _DefineComboSearchGrid()


*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

STATIC PROC CreateCSBoxGrid( cParentName, cCSBoxName, aitems, cCSBoxRow, cCSBoxCol,lAnyWhere, aHeaders, aWidths ) 

   LOCAL nFormRow       := thisWindow.row
   LOCAL nFormCol       := thisWindow.col
   LOCAL nControlRow    := this.row
   LOCAL nControlCol    := this.col
   LOCAL nControlWidth  := this.width
   LOCAL nControlHeight := this.height
   LOCAL cCurValue      := this.value
   LOCAL aResults       := {}
   LOCAL nContIndx      := GetControlIndex( this.name, thiswindow.name )   
   LOCAL result         := 0
   LOCAL nItemNo        := 0
   LOCAL nListBoxHeight := 0
   LOCAL caret          := this.CaretPos
   
   LOCAL cCSBxName := 'frm' + cCSBoxName
   
   
   
   IF !EMPTY(cCurValue)
   
      IF _HMG_SYSDATA [ 23, nContIndx ] # -1                     // _HMG_aControlContainerRow
         nControlRow += _HMG_SYSDATA [  23, nContIndx ]          // _HMG_aControlContainerRow
         nControlCol += _HMG_SYSDATA [  24, nContIndx ]          // _HMG_aControlContainerCol 
      ENDIF   
   
      FOR nItemNo := 1 TO LEN(aitems)
         IF UPPER( aitems[ nItemNo,1 ] ) == UPPER( cCurValue )
            EXIT // item selected already
         ENDIF
         IF UPPER( LEFT( aitems[ nItemNo,1 ], LEN( cCurValue ))) == UPPER(cCurValue)
            AADD( aResults, aitems[ nItemNo ] )
         ENDIF
      NEXT nItemNo
      
      IF LEN( aResults ) > 0
      
         nListBoxHeight := MAX(MIN((LEN(aResults) * 16)+60,thiswindow.height - nControlRow - nControlHeight-10),40)
         
         DEFINE WINDOW &cCSBxName ;
            AT     nFormRow+nControlRow+20, nFormCol+nControlCol ;
            WIDTH  nControlWidth+6 ;
            HEIGHT nListBoxHeight+nControlHeight ;
            TITLE '' ;
            MODAL ;
            NOCAPTION ;
            NOSIZE 
         
            ON KEY UP     OF This.Window ACTION _CSGridDoUpKey()  
            ON KEY DOWN   OF This.Window ACTION _CSGridDoDownKey()
            ON KEY ESCAPE OF This.Window ACTION _CSGridDoEscKey(cParentName, cCSBoxName) 
            
            DEFINE TEXTBOX _cstext
               ROW           3
               COL           3
               WIDTH         nControlWidth
               HEIGHT        nControlHeight
               FONTNAME      this.fontname
               FONTSIZE      this.Fontsize
               TOOLTIP       this.tooltip
               FONTBOLD      this.fontbold
               FONTITALIC    this.fontitalic
               FONTUNDERLINE this.fontunderline
               BACKCOLOR     this.backcolor
               FONTCOLOR     this.fontcolor
               ON CHANGE     _CSGridTextChanged( cParentName, aitems, cCSBoxName, lAnyWhere )
               ON ENTER      _CSGridItemSelected( cParentName, aitems, cCSBoxName )
            END TEXTBOX
            
            DEFINE Grid _cslist
               ROW         nControlHeight+3
               COL         3
               WIDTH       nControlWidth
               HEIGHT      nListBoxHeight + 25
               ITEMS       aResults
               ON DBLCLICK _CSGridItemSelected( cParentName, aitems, cCSBoxName )
               VALUE       1
               HEADERS     aHeaders
               WIDTHS      aWidths   
            END Grid
            
         END WINDOW
         
         SetProperty( cCSBxName, '_cstext', "VALUE", cCurValue )
         SetProperty( cCSBxName, '_cstext', "CaretPos", caret )
         
         ACTIVATE WINDOW &cCSBxName
         
         
      ENDIF
   ENDIF   
  
RETURN // CreateCSBoxGrid()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._
   
STATIC PROC _CSGridTextChanged( cParentName, aItems, cTxBName, lAnyWhere )

   LOCAL cCurValue      := GetProperty( ThisWindow.Name, '_cstext', "VALUE" ) 
   LOCAL aResults       := {}
   LOCAL nItemNo        := 0
   LOCAL nListBoxHeight := 0
   LOCAL nParentHeight  := GetProperty(cParentName,"HEIGHT")
   LOCAL nParentRow     := GetProperty(cParentName,"ROW")
   
   DoMethod( ThisWindow.Name, "_csList", 'DeleteAllItems' ) 
   
   FOR nItemNo := 1 TO LEN(aitems)
      IF lAnyWhere
         IF AT(UPPER(cCurValue),UPPER(aItems[nItemNo,1])) > 0
            AADD(aResults,aitems[ nItemNo ])
         ENDIF            
      ELSE
         IF UPPER( LEFT( aitems[ nItemNo,1 ], LEN(cCurValue))) == UPPER(cCurValue)
            AADD(aResults,aitems[ nItemNo ])
         ENDIF
      ENDIF   
   NEXT nItemNo
   
   IF LEN(aResults) > 0
      FOR nItemNo := 1 TO LEN(aResults)
         DoMethod( ThisWindow.Name, "_csList", 'AddItem', aResults[ nItemNo ] ) 
      NEXT i
      SetProperty( ThisWindow.Name, "_csList", "VALUE", 1 ) 
   ENDIF
   
   nListBoxHeight := MAX(MIN((LEN(aResults) * 16)+6,(nParentHeight + nParentRow - ;
                    GetProperty( ThisWindow.Name, 'ROW' ) -  ;
                    GetProperty( ThisWindow.Name, "_csText", 'ROW' ) -  ;
                    GetProperty( ThisWindow.Name, "_csText", 'HEIGHT' ) -  14)), 40) 
   
   SetProperty( ThisWindow.Name, "_csList", "HEIGHT", nListBoxHeight +25) 
   SetProperty( ThisWindow.Name, "HEIGHT", nListBoxHeight +  25+ GetProperty( ThisWindow.Name, '_cstext', "HEIGHT" ) ) 

RETURN // _CSGridTextChanged()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._

STATIC PROC _CSGridItemSelected( cParentName, aitems, cTxBName )
local cFormName := ThisWindow.Name
local aLine := {}

   if GetProperty( ThisWindow.Name, "_csList", "VALUE" ) > 0
  
      nListValue := GetProperty( ThisWindow.Name, '_csList', "VALUE" )
      aLine := GetProperty( ThisWindow.Name, '_csList', "ITEM", nListValue ) 
      cListItem  := aLine[1] 
      SetProperty( cParentName, cTxBName, "VALUE", cListItem )
      
      SetProperty(cParentName,cTxBName,"CARETPOS",;
                    LEN( GetProperty( cFormName, '_csList', "ITEM",; 
                         GetProperty( cFormName, '_csList', "VALUE" ) ) ) )
      
      DoMethod( ThisWindow.Name, "Release" ) 

      
   ENDIF  
          
RETURN // _CSGridItemSelected()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._

STATIC PROC _CSGridDoUpKey()

   IF GetProperty( ThisWindow.Name, '_csList', "ItemCount" ) > 0 .AND. ;
      GetProperty( ThisWindow.Name, '_csList', "VALUE" ) > 1
   
      SetProperty( ThisWindow.Name, '_csList', "VALUE", GetProperty( ThisWindow.Name, '_csList', "VALUE" ) - 1 )
     
      
   ENDIF
   
RETURN // _CSGridDoUpKey()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._

STATIC PROC _CSGridDoDownKey()

   IF GetProperty( ThisWindow.Name, '_csList', "ItemCount" ) > 0 .AND. ;
      GetProperty( ThisWindow.Name, '_csList', "VALUE" )     < ;
      GetProperty( ThisWindow.Name, '_csList', "ItemCount" )
      
      SetProperty( ThisWindow.Name, '_csList', "VALUE", GetProperty( ThisWindow.Name, '_csList', "VALUE" ) + 1 ) 
      
   ENDIF

RETURN // _CSGridDoDownKey()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._

STATIC PROC _CSGridDoEscKey(cParentName, cCSBoxName)

   SetProperty( ThisWindow.Name, '_csText', "VALUE",'')
   
   

   SetProperty( cParentName, cCSBoxName, "VALUE",'')

   DoMethod( ThisWindow.Name, "Release" )
    

RETURN // _CSGridDoEscKey()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._



Everything works fine. The only problem is we can not the blue background color as in listbox even though the grid item is selected. The reason is, listbox is by default having blue color for the selected item both in focus state and non-focus state. Where as, grids by default make it grey when not in focus.

If we can get a work around using dynamicbackcolor, this would also be solved, I think.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

jparada
Posts: 291
Joined: Fri Jan 23, 2009 5:18 pm
Been thanked: 4 times

Post by jparada » Fri Apr 23, 2010 6:02 pm

Hi,

I appreciate your effort and your work, your example works well and includes "almost" all the features that ComboSearchBox have, except one, as you well commented which is that the Grid control does not get the focus.
The only problem is we can not the blue background color as in listbox even though the grid item is selected. The reason is, listbox is by default having blue color for the selected item both in focus state and non-focus state. Where as, grids by default make it grey when not in focus.
Thanks for this explanation, I did not know that this is the normal behavior of the listbox control.
If we can get a work around using dynamicbackcolor, this would also be solved, I think.
I have no ability to implement a "workaround", perhaps someone can help here.

Anyway, if this is not possible, then I will have to try with other alternative, or use "at the moment" ComboSearchBox, but once the event on change works well.

Thanks for your effort

Best Regards
Javier

Post Reply