Highlighting the result of a search in a grid cell

Is there a way to highlight a part of a grid cell.

I want to do a search and show the results in a grid and the text found I want to highlight or give a different color.

Is this possible?

  • There are a variety of grid properties that allow you to color grid cells, from

    MODIFY Screen1-Gd-1, X = 1, Y = 2, CELL-COLOR = 69,

    or use REGION-COLOR - if you take the sample gridctl.cbl and edit the   when msg-goto-cell-mouse to

                    modify grid-1, region-color = 67

    When you run the program and highlight cells in a column or row and column the color changes.

  • modify Screen1-Gd-1, start-x=x-2 x=4 start-y=y-2 y=4

              REGION-COLOR  "160"

    this would give you a red background in cells x=2 y=2 and go through x=4 y=4

    six cells changed

    The start-x start-y is the property where the region begins and the x y property is where the region ends

  • We use a grid where the user can click on one row or more rows as the mouse drags down and the region color changes.  Here's the event procedure:

    grid-1-handler.

         evaluate event-type

             when msg-begin-entry

                  move 1 to sgl-item-selected-sw    

                  move 0 to region-selected-sw  

                  inquire grid-1 x in x-column

                                 y in y-row

                         cell-data in cell-report-name        

                  if x-column = 1

                     perform call-wordpad-paragraph

                  end-if

    ***********event-action-fail prevents the cells from becoming active

                  move event-action-fail to event-action

                  modify grid-1 region-color = black

             when 16396

                  move 1 to region-selected-sw        

                  move 1 to sgl-item-selected-sw

                  inquire grid-1 x in drag-start-column

                                 y in drag-start-row

                         cell-data in cell-report-name

                  modify grid-1 region-color = black  

                  move drag-start-row to drag-end-row

                                         present-row-number  

                  move drag-start-column to drag-end-column

                                            present-column-number  

             when msg-begin-drag

                  move 1 to region-selected-sw

                  move 0 to sgl-item-selected-sw

                  inquire grid-1 x in drag-start-column

                                 y in drag-start-row  

             when msg-goto-cell-drag

                  modify grid-1  

                         region-color = 175

                  move 1 to region-selected-sw

                  move 0 to sgl-item-selected-sw

             when msg-end-drag

                  move 1 to region-selected-sw

                  move 0 to sgl-item-selected-sw

                  modify grid-1 region-color = 175                

                  inquire grid-1 x in drag-end-column

                                 y in drag-end-row

                  move drag-end-column to present-column-number

                  move drag-end-row    to present-row-number

             when other

           end-evaluate.

  • We use a grid where the user can click on one row or more rows as the mouse drags down and the region color changes.  Here's the event procedure:

    grid-1-handler.

         evaluate event-type

             when msg-begin-entry

                  move 1 to sgl-item-selected-sw    

                  move 0 to region-selected-sw  

                  inquire grid-1 x in x-column

                                 y in y-row

                         cell-data in cell-report-name        

                  if x-column = 1

                     perform call-wordpad-paragraph

                  end-if

    ***********event-action-fail prevents the cells from becoming active

                  move event-action-fail to event-action

                  modify grid-1 region-color = black

             when 16396

                  move 1 to region-selected-sw        

                  move 1 to sgl-item-selected-sw

                  inquire grid-1 x in drag-start-column

                                 y in drag-start-row

                         cell-data in cell-report-name

                  modify grid-1 region-color = black  

                  move drag-start-row to drag-end-row

                                         present-row-number  

                  move drag-start-column to drag-end-column

                                            present-column-number  

             when msg-begin-drag

                  move 1 to region-selected-sw

                  move 0 to sgl-item-selected-sw

                  inquire grid-1 x in drag-start-column

                                 y in drag-start-row  

             when msg-goto-cell-drag

                  modify grid-1  

                         region-color = 175

                  move 1 to region-selected-sw

                  move 0 to sgl-item-selected-sw

             when msg-end-drag

                  move 1 to region-selected-sw

                  move 0 to sgl-item-selected-sw

                  modify grid-1 region-color = 175                

                  inquire grid-1 x in drag-end-column

                                 y in drag-end-row

                  move drag-end-column to present-column-number

                  move drag-end-row    to present-row-number

             when other

           end-evaluate.