1. Kirankumar Chavadi
  2. PowerBuilder
  3. Wednesday, 22 January 2020 06:13 AM UTC

How to change column border color (to red) in DataWindow?

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 22 January 2020 18:21 PM UTC
  2. PowerBuilder
  3. # 1

Hi Kirankumar;

  As you can see from the various replies to your question ... the DWO column or the Modify() command does not support what you need. I would suggest opening a Support Ticket as an enhancement request to the DWO property and Modify command, as follows:

1) Add a "Border Color" property to DWO's

2) Add "expression" support for this new property

3) Support the Modify command as follows ...

   For example:  <DC>.Modify ( "<Columnname>.BorderColor=' <rgb value> ' ")

Food for thought

Regards ... Chris

Comment
  1. Michael Kramer
  2. Wednesday, 22 January 2020 21:02 PM UTC
Enhancement as I see it is no earlier than 2019 R3, perhaps later depending on priorities. Until available in system classes, it is the art of the possible.
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Wednesday, 22 January 2020 15:51 PM UTC
  2. PowerBuilder
  3. # 2

How to create/destroy a rectangle inside a DW to border a specific object inside that DW

// ---- FUNCTION of_RemoveWarningBox(datawindow adw, string as_name)
// Removes named warning-box
string ls_status

ls_status = adw.Modify('destroy ' + as_name)
if ls_status <> "" then return -1 // Error occurred
return 1

NOTE: You have to convert back and forth PBU <=> pixels to adjust coordinates correctly.

Create function has option to display rectangle only in specific row unless you call using row = 0.

// ---- FUNCTION of_CreateWarningBox( datawindow adw, dwobject dwo, long row, string as_name )
// Creates warning-box around <dwo, row>. Box identified by <name>.
// NOTE: Expect measured in PBUs
constant long BoxColor = 192	// Less "glossy" than 255
long boxX, boxY, boxW, boxH
string ls_status, ls_object, ls_visible

// Calculate property values
// VISIBLE: Only visible in row - unless row=0
if (row = 0) then
	ls_visible = "1"
else
	ls_visible = "1~tif( GetRow( ) = " + string(row) + ", 1, 0)"
end if

// X, Y: (-1 px)  --  Width, Height: (+3 px)
boxX = PixelsToUnits( (UnitsToPixels( long(dwo.X), XUnitsToPixels!) - 1), XPixelsToUnits!)
boxY = PixelsToUnits( (UnitsToPixels( long(dwo.Y), YUnitsToPixels!) - 1), YPixelsToUnits!)
boxW = PixelsToUnits( (UnitsToPixels( long(dwo.Width), XUnitsToPixels!) + 3), XPixelsToUnits!)
boxH = PixelsToUnits( (UnitsToPixels( long(dwo.Height), YUnitsToPixels!) + 3), YPixelsToUnits!)

// Define box syntax
ls_object = 'rectangle(name=' + as_name
ls_object += ' band=' + dwo.Band
ls_object += ' pen.color="' + string(BoxColor) + '"'
ls_object += ' visible="' + ls_visible + '"'
ls_object += ' x="' + string(boxX) + '"'
ls_object += ' y="' + string(boxY) + '"'
ls_object += ' width="' + string(boxW) + '"'
ls_object += ' height="' + string(boxH) + '"'
ls_object += ' brush.hatch="7" pen.style="0" pen.width="1" background.mode="2" )'

ls_status = adw.Modify('create ' + ls_object)
if ls_status <> "" then return -1 // Error occurred
return 1

 

HTH /Michael

Comment
  1. Kirankumar Chavadi
  2. Thursday, 23 January 2020 09:22 AM UTC
It worked!



Thank you so much Michael
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Wednesday, 22 January 2020 13:44 PM UTC
  2. PowerBuilder
  3. # 3

René is right. UI Themes to change - or display rectangle "on top".

Alternative is use background of the control.
I have used that quite successfully many times.

NOTE on Rectangle
If your edit control has 3D Lowered or 3D Raised border that border displays partially "outside" the control! Example of position + size both in pixels not PBUs:

  • My Edit control
    • X, Y = 52, 7
    • Width x Height = 70 x 18
  • My rectangle
    • X, Y = 51, 6
    • Width x Height = 73 x 21

If you rectangle is identical position + size it will look like drawn inside the control; not on top of border.

HTH /Michael

Comment
  1. Kirankumar Chavadi
  2. Wednesday, 22 January 2020 14:37 PM UTC
Thank you for your inputs Michael

Since we are trying to implement this feature in an existing application, modifying all DWs is not feasible.

I am looking for a solution which can be written in Ancestor/Child window scripts.
  1. Helpful
  1. Michael Kramer
  2. Wednesday, 22 January 2020 15:51 PM UTC
See my new reply on how you can add/remove such box using generic code. I haven't tested code yet so watch out for minor syntax mistakes and test in your own code.

  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 22 January 2020 06:29 AM UTC
  2. PowerBuilder
  3. # 4

The only way I know are Themes.

Comment
  1. Kirankumar Chavadi
  2. Wednesday, 22 January 2020 06:41 AM UTC
Thank you René Ullrich!



Actually I need to change column color at run time, to highlight missed out mandatory fields
  1. Helpful
  1. René Ullrich
  2. Wednesday, 22 January 2020 07:29 AM UTC
So I think you have to draw your own border (rectangle) or you use another marker (e.g. background color).
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.