INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Datawindow

Changing background color of changed fields in DW by mbalent
Posted: 18 Jun 10

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)

Back to Sybase: PowerBuilder FAQ Index
Back to Sybase: PowerBuilder Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close