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

Dynamically Disabling Grid Row if Field is True

Status
Not open for further replies.

dantheinfoman

Programmer
May 5, 2015
131
0
0
US
Hi All,

I've had success getting the rows that have C_IMPORTED = .T. to be red, but I also want to disable the entire row so that people can't edit a record it if has been flagged as 'imported'.

Here's what I have so far, both in the form INIT event:
Code:
***colors and disabling imported records***
thisform.grdComAll.setall("DynamicBackColor","iif( !EMPTY(c_imported), rgb(255,204,204), rgb(255,255,255) )","Column")

This part doesn't work:
Code:
thisform.grdcomAll.SetAll("Enabled","iif( !EMPTY(c_imported), .F.,.T.)")

Can anybody help me. I've read forums galore about using AfterRowColChange, and have had limited success in making text and checkboxes ReadOnly using this in the AfterRowColChange:
Code:
this.ReadOnly = (c_imported)

However, people can still change the comboboxes, even if it's 'ReadOnly'. So then I tried to make those three comboboxes disabled in the AfterRowColChange:
Code:
LPARAMETERS nColIndex
this.ReadOnly = (c_imported) 
this.clmCType.cmbCtype.Enabled = !(c_imported)
this.clmTopic.cmbComTop.Enabled = !(c_imported)
this.cmbConfer.cmbConfer.Enabled = !(c_imported)

But it's wonky and you have to click on two different rows/columns before it makes EVERY ROW either Enabled or disabled for those comboboxes.


I don't have much hair left, but I'm tempted to pull the remainder out. Please help if you can. I'm wondering if there's a SETALL I can use to make certain rows entirely disabled and the rest enabled.

Thanks!

Dan
 
Dave has the solution for you. You can SetAll any property, but an IIF expression only can make a dynamic difference in DYNAMICxyz properties and enabled is not one of them.

You could also set any Dynamic property to call a method instead of using an IIF expression. In that method you still return whatever dynamic value (eg the color), but noone hinders you to do anything else at that point, eg setting Enabled. There just is not an enabled per row, you can enable/disable the columns controls.

You could create a textbox class reacting to being activated in its WHEN event and return .F. from there, if its backcolor is red, for example. But having two controls, one enabled, one disabled maybe easier and more to the point, you don't want your code to fail, just because colors change.

Bye, Olaf.
 
Hi DSummZZZ and Olaf,

Yes, this worked for me! Thank you for the tip and confirmation!

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top