Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Navigating in a grid 2

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
There is a grid; the RecordSource is cursor tDetails. The user can navigate up and down, but he may only enter a value into Column6 (tdetail.tQty). This is handled by setting the enabled property for columns 1-5 to be False.

This works fine and as I navigate up and down the cell in Column 6 is highlighted (blue background).

I would now like to restrict the entry into Column 6 (the tQty field), so that entry is only allowed when the line item is still outstanding.

To do that, I first coded the grid’s AfterRowColChange() method to set the MyGrid.AllowCellSelection property. This worked up to a point, but the effect was that on an ineligible row, the whole row was highlighted, and this was not what I wanted.

I then coded the grid’s AfterRowColChange() method to set MyGrid.Column6.enabled property accordingly.

This also works up to a point, but I am finding that, when positioned on an eligible cell, the background is still white and I cannot enter a number. Only when I attempt to move out of the cell (with {LEFTARROW}) does the cell become highlighted and blue. So I have tried including KEYBOARD ’{LEFTARROW}’ and this is how I have left the code at present.

Code:
LPARAMETERS nColIndex
*!*	   IF tDetail.tStatus = "C"
*!*	      This.AllowCellSelection = .F.
*!*	     ELSE
*!*	      This.AllowCellSelection = .T.
*!*	      ENDIF

   IF tDetail.tStatus = "C"
      This.Column6.enabled = .F.
     ELSE
      This.Column6.enabled = .T.
      KEYBOARD '{LEFTARROW}'
      ENDIF

But if there is a better way of achieving the result, I would like to know.

Thanks. Andrew
 
how about on the gotFocus of the text box in column 6?

this.readonly = (tDetail.tStatus <> 'C')

Ez Logic
Michigan
 
You're still enabling or disabling the whole column. If you'd now Refresh() the grid it'll show up with all or no rows enabled.
How about solving this with DynamicCurrentControl instead of this hack?
You can have two textboxes, one enabling one disabling dataentry. Ideally return .F. from When instead of readonly=.t. or enabled=.f., this has the best/fsatest response time in accidentally clicking on such a cell.

Of course then set column6.sparse=.f. to show the one or other control depending on the tDetail.tStatus value via IIF(tDetail.tStatus="C","disabledtextbox", "enabledtextbox"), where disabledtextbox and enabledtextbox must be the names of the textboxes you add to the grid column.

Bye, Olaf.
 
Thank you Ez and Olaf. Sorry for the delay. Thank you particularly EzLogic. Your helpful suggestion of this.readonly does the trick. I have also set :

DynamicForeColor "IF(. ., RGB(0,0,0), RGB(127,127,127))"

for this Text1, to indicate (for some rows) that this element may not be edited.

You have saved me much research, so please take a Star, EzLogic.

Andrew M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top