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!

Modify( )

Status
Not open for further replies.

beti

Programmer
Oct 6, 2002
26
US
Hi,

I have try the following statement but nothing happens. Anyone know why? I'm trying to do a loop in the datawindow,
if pass certain verification...it will change that particular row to red.


for n = 1 to dw_datawindow.rowcount()
.....
....
...
if xx = yy then
dw_datawindow.modify("columnname(n).color=255")
end if
next

Can anyone please help me with this question? thanks
 
Hi,

try dw_datawindow.modify("columnname[n].color=255")

Otherwise, an other way to change properties for a peculiar row is to mix coding and dw properties expressions.

- Add to your dw, a column "Status" (string) default value = 'OK'
- Add an expression in color property of the column you want the color change to red
ex : if(status='NOK' , rgb(255,0,0), rgb(0,0,0))
- Change your script :

for n = 1 to dw_datawindow.rowcount()
.....
....
...
if xx = yy then
dw_datawindow.SetItem(n,columnname,'NOK')
end if
next

Hope it will help

Thierry
 
The parm to modify() is type string. If you do something like:

lsModString = "columnname(" + string(n) + ").color=255"
lsResult = dw_datawindow.modify( lsModString )

it should work.

I suspect that if you ran the original example with debug and caught the return from modify() as above you would have found a message indicating that the modify string was bad.

See the PB help for more complex examples of modify strings.
 
Beti,

You cannot modify the color of a column on JUST one row without using an expression. If you don't use an expression, it gets applied to all the rows. To achieve what you are trying to do, use a dynamic-expression for the column in the dw painter (so you don't have to code any further) such as:

column -> Properties -> Expressions -> Color:
If( <x=y>, 255, 0 ) // Red or Black

Alternatively, use a similar expression for the Modify() function:

dw.Modify( &quot;col.Color = '0~tIf( x=y, 255, 0 )'&quot; )

Further, even if your logic works, it is INCOMPLETE - setting the color of only those rows where xx = yy; it should also set the default color for the other rows! Otherwise, next time the control passes this logic, the colors may get over-lapped. For other colors, you may have to use the RGB() function.

---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top