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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

control textbox in grid

Status
Not open for further replies.

nevin2007

Programmer
Aug 21, 2009
31
IR
hi all
i have a grid and wants to prevent user changing content of some cell in a column but when is set Enable property to .f. all column disabled and when used WHEN METHOD by return .f. Right click method dont fire (i use right click to active a popup menu for each cell. some cell can have change content and some are lock and user must choose unlock command from popup menu)

can anyone help me ?

 
The simplest way would be to set ReadOnly property for the column in AfterRowColChange method depending on your condition.
 
Do you want to prevent them editing every row in the column in question? If so, make the column ReadOnly.

But if you want to prevent them editing certain rows, depending on a condition, one way would be to place two textboxes in the column. In one of them, set ReadOnly to .t. and in other keep it .f. Then use the column's DynamicCurrentControl to activate the relevant control according to your condition.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mike - you don't need to use DynamicControl to control ReadOnly status. You need to do this in ARCC - simply set Column ReadOnly status depending on your condition.
 
All excellent suggestions above, but if you dont want to use 2 controls, try this in the Right Click for the Textbox;
Code:
if << what your condition is >>
      =messagebox("Cannot change this record",64,"No Change")
      this.value = nvl(oldval("<<fieldname>>","<<tablename>>"),[b]""[/b]) 
      return .f.
Else
   ......
   display your popup  
endif

The textbox must have a control source and the NVL must be set to the field type i.e. if character then "" / Numeric = 0, date = {}
 
If you dont want the user changing the contents based on a condition you can do the same in the Valid() of the textbox.

Code:
if not empty(this.value) and ;
  nvl(oldval("<<fieldname>>","<<tablename>>"),"") # this.value      
  =messagebox("Cannot change this record",64,"No Change")      
  this.value = nvl(oldval("<<fieldname>>","<<tablename>>"),"")       
  return .f.
Else   
  this.rightclick()
endif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top