PowerBuilder – Prevent Individual Column Resizing in Grid DW

Posted on Monday, December 20th, 2010 at 8:20 pm in

Many applications I’ve worked on have grid datawindows that include columns which display graphics to indicate some sort of common functionality such as code inquiry, row selection indicator, etc. Generally you set the ‘display as bitmap’ property on the column and go from there. The problem with these columns, however, is if the user resizes them, they most likely will look very unattractive. Unless you prevent resizing of all columns in the datawindow you have this potental problem.

A simple way to prevent this is to place a rectangle object in the header band of the graphic column with the Layer property set to foreground. Set the line color and fill color properties to Transparent so it is invisible to the user. To keep the rectangle in the proper place if the order and/or widths of other columns are changed, add the following to the X, Y, Height, and Width expressions of the rectangle:

// X 
Integer(describe('bitmap_column_name.x')) - 15
Integer(describe('bitmap_column_name.Y')) - 5
Integer(describe('bitmap_column_name.Height')) + 20
Integer(describe('bitmap_column_name.Width')) + 25

This also makes the rectangle somewhat larger than the column header since if the mouse pointer is able to touch the grid line itself, it will resize the column. These settings were able to prevent this except for the very top right corner of the column. I assume this happens due to clipping of the Y position by the datawindow control.

In the clicked event of the datawindow control add the following:

IF this.GetObjectAtPointer() = 'rectangle_name~t1' THEN

Make sure this is prior to any ‘If Row < 1 then RETURN’ logic in the event.

You might also be interested in