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

Changing background color of changed fields in DW

Datawindow

Changing background color of changed fields in DW

by  mbalent  Posted    (Edited  )
You have a datawindow with a bunch of rows which can be edited and when the user pulls up the data set and proceeds to change values in a variety of columns and a variety of rows you want to indicate to him that the specific row/column has been changed by altering the background color.

I have a solution which works. It involves:
1) adding a column on the datawindow object
2) populating that column in the itemchanged event
3) putting an expression on the background color property of each visible column in the datawindow object you want the color to change when edited

1) I added a string column called 'change' (not a computed col) to my datawindow object.

2) in the Itemchanged event on the Datawindow
Code:
// build a list of the column numbers which have been edited.  You can enhance this to account for errors, etc.

string ls_desc, ls_value, ls_d, ls_prev
integer li_rc

ls_desc =  dwo.name + '.ID'

ls_d = describe(ls_desc)
ls_prev = getitemstring(row,'change')
IF IsNull(ls_prev) THEN ls_prev = ''
ls_value = ls_prev + '[' + ls_d + ']' // append new value
li_rc =    this.setitem( row, 'change', ls_value)
3) in the background color of a column called 'box3' put the following expression
Code:
IF (pos(change[0], '[' + describe('box3.ID') + ']') > 0, RGB(255,255,0),RGB(255,255,255))
As an alternative, you can make step three dynamic by adding the following in an open/postopen type event:
Code:
dw_1.retrieve( )

dw_1.setredraw( False)

// get list of columns in the order they are displayed which may not be the same as their column number order
ll_max = Integer(dw_1.Object.DataWindow.Column.Count)  // determine number of columns
FOR ll_i = 1 TO ll_max STEP 1
	// only need the visible columns
	IF dw_1.describe("#" + String(ll_i) + ".Visible") = '1' THEN
		// first set the mode to opaque
		ls_modstring = dw_1.describe( "#" + string(ll_i) +  ".Name") +  ".Background.Mode='0'"
		ls_msg = dw_1.Modify(ls_modstring)
		// set the color of the cells
		ls_modstring = dw_1.describe( "#" + string(ll_i) +  ".Name") +  ".Background.Color =  ~"536870912~t IF (pos(change[0],~'[~' + describe(~'" +  dw_1.describe( "#" + string(ll_i) +  ".Name") + ".ID~') + ~']~') > 0, RGB(255,255,0),RGB(255,0,255))~""
		ls_msg = dw_1.Modify(ls_modstring)
	END IF
NEXT

dw_1.setRedraw(true)
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top