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

Dynamic X-position of a autosize column

Status
Not open for further replies.

mistermusic

Programmer
Jun 10, 2009
9
0
0
US
Hi there

I am using PB 11.5

I have a problem with a datawindow column that has its autosize.height property on YES.

I want to be able to change the columns X-Position dynamicly. The problem is that after I modify the datawindow the position of the column is still displaied at its original position. However when I click that control, it moves to the new position. But as soon as I click another column, it returns to its old position...

I am using this code:
-------------------------------------------
LONG l_x

l_x = long(dw_2.describe("autosizefield.x"))

l_x = l_x + 20

dw_2.modify("autosizefield.x=" + string(l_x))
-------------------------------------------

Thanks for your inputs....
 
->First, check if you are also using the 'slide left' property when using the autosize height.

->Does the problem also happen when you (temporarily) de-mark the autosize height property?

quote:
"The problem is that after I modify the datawindow the position of the column is still displaied at its original position. However when I click that control, it moves to the new position. "
->Could it be that if you do a dw_control.SetRedraw(True)
this 'click' is no longer necessary?

Then another thing of which I'm not so sure but might be important if I'm right (I warn You, not sure at all of this being your case):
----------------------
you've mentioned this code:
l_x = long(dw_2.describe("autosizefield.x"))

the first time it executes, it'll give you the correct position.
the second time (after having modified the original x position), I'm not so sure whether it'll give you the original position or the modified position ... If so (getting the original position, though you modified it), you should check out the ....

Evaluate() function ....

,.. to obtain the true x pos. This function usually is a bit weary due to quotes inside quotes, but in your case it shouldn't be to difficult to make it work and give you the true coordinates.

"But as soon as I click another column, it returns to its old position..., "
-> is there an expression in the x attribute of the column?
-> is there code in the itemfocuschanged event of the dw-control that might affect?

I'd start to check the behaviour, without the autosize-height attribute. (and more important posible 'slide-left')


regards,
Miguel L.
 
okay I decided to do my homework a little bit better.


First of all: no need to use the evaluate function. When you dynamically change the x position, the next time the Describe( ) will return correctly the changed new position.
(the evaluate( ) is only necesary to obtain the result of expresions used in attributes).

-> I simulated your situation and found out that, without the autosize height, there's no problem at all in doing what you do.

-> then I used autosize height and found out this behaviour:
1) you definitely need to do a setRedraw(). Without it, it didn't redraw the left space (cleared by moving the column 20 to the right). It looked like my column was every time wider, when repeating your code (I put it in a commandbutton).
The truth was that it simply didn't redraw the cleared area.
2) when there's no value in the column with autosize height, there's no height at all... you have to write a value in it and won't see it untill you change focus to another column .... I'm using version 10.0 now and didn't bother to install the patches yet, so this 'new' behaviour (at least to me) might be "resolved" already, but in previous versions a column would never shrink to a height less than the height you give it when designing the datawindow. On the other hand they might just have changed the autosize behaviour to shrink to a minimum past design limits.

Hope it helps and sorry for any misleading information before.


regards,
Miguel L.
 
A last thing I found was this:

using the 'slide left' I found the second columna aligned vertically with the first one, while not having a value in it.
writing a value of 'a' in the first(left) columna, the second moved to the right a bit. Writing a value 'abc' the second moves a little bit more. Bringing down the contents of the first column to 'a' again, the second one comes back to the original position when writing 'a' for the first time.

Now: after doing several modifies to move the second column to the right, the left-align behaves quite diferently: it doesn't come back to the positions as described before.
Must have something to do that pb reads the initial coordinates of columns and it all screws up when doing manual x-pos modifications.

regards,
Miguel L.
 
Hi

First of all let me thank you for all your efforts!! Unfortunately, it didn't work out for me.

In our version of PB (11.5.1 with all the latest patches) an empty autosize-height-field is visible (see pic 1).

In picture 2 you can see what happens after I move the field with my function, click on it and put "abc". Looks like the frame of the field's original position is still displaied.

In picture 3 you see what happens after I leave the "abc" field and insert another row...

To me it seems like this is some sort of PB-Bug?

 
 http://www.schwarzwald-vagabunden.de/transfer/autosize.JPG
Hello,

Great way to document your 'problem':

Me too I had the same problem, described in pic 2, after doing the move to the right. (leaving the white area at the left of 'abc' without redrawing, while it should show in blue).
-> That problem I solved it by doing a dw_control.setRedraw(true) after the modify of the x.position. (using pb 10). If in your case it doesn't help, you might try to do a dw_control.POST setRedraw(true). (Don't know where/when you are doing the modify() ).

Pic 3: As for the situation of the column showing itself at the original x position, after an insertrow(). You might try to do the next: in the rowfocuschanged event, you could keep track of the 'previous row' (long il_previous_row) and adjust the x position of your column to the same position as the column in the previous row, using describe() and modify() ???????

And ... yes ... there are probably some bugs with autosize height (did you get the same results when not using the autosize height?)
The behaviour has been changing throughout several versions and it wouldn't surprise me at all.

Hope it helps someway.

regards,
Miguel L.
 
I noticed (see pic 2), that the focus is inside the column that doesn't redraw well. if the setRedraw() doesn't work, try to do a SetColumn('first_column') before you do the modify of the x position of the 'second_column'), then do a setredraw(true) and if you want the focus to end up in the second column: SetColumn('second_column')



regards,
Miguel L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top