column widths in dbpro - Forum

Forum Navigation
You need to log in to create posts and topics.

column widths in dbpro

Hello
How to set the Width of columns in Db Pro so that it is automatically adjusted based on the size of the window or Restangle size.

@s7shanbe

You need to get the window width ([PubWidth]) and column widths (dbpGetColumnWidths) programmatically, then you can calculate and set the new width of all columns or, for example, only one right column. You can place this subroutine on the window resizing event in the project properties.

@s7shanbe

Vadim is correct. Now if you wanted, say, all of your columns of equal widths, you could GetObjectInfo width of your rectangle divided by the number of columns or, you could adjust your percentages per column to achieve different widths but still be in proportion when you resize the pub.

Let's say you have 10 columns and your rectangle is 700: Math "[RectWidth]/10" "0" "[NewColWidth]" Your new column width is 70.

Now, let's say you have 5 columns, equal widths would be 20% of your rectangle width. But, let's say you want your first column to be 40% and the rest equal widths:

Math "[RectWidth]*.4" "0" "[NewColWidth1]"
Math "[RectWidth]-[NewColWidth1]" "0" "[NewColWidthx]" or SetVar "[NewColWidthx]" "[RectWidth]-[NewColWidth1]"
Math "[NewColWidthx]/4" "0" "[NewColWidth2]"

And so on... I hope I got my maths right but you get the principle. And remember, you can't let your NewColWidths to add up to more than your rectangle width or they'll go beyond the right side of it. This principal could also be used of you have any number of columns and you only want your first two or three columns showing while the user will have to scroll right to see the rest. This would be good to show information at a glance or first pertinent info and scroll for details.

Hope this helps.

Vadim has reacted to this post.
Vadim