Link to home
Start Free TrialLog in
Avatar of baudspeed
baudspeed

asked on

Flexgrid onload starts up at negative position but is actually dead center on form (FULLMARKS )

The name almost explains it all, but i will elaborate.
In the form load event, i need to get the position (height &  left) of a specific flex grid that sits on a tab sheet (which i also get the height and left from)

The problem is that in the form load event, some times the flexgrid appears to be sitting at  -1700 when in actual fact it sits at 120. The flexgrid is set to visible = false
however, i dont beleive this to be the problem, since this is intermitant, and only happens sometimes when the form loads. I have tucked do events around it everywhere thinking that it could be a problem with the form loading and then having to execute the code, meanwhile not centering the form correctly, but this does not seem to be the case.


Has anyone else had this issue? or something similar? A clear and correct response will net you full marks + A+
Avatar of Dabas
Dabas
Flag of Australia image

Hi baudspeed,
Are you using any positioning statements within Form_Load (Setting any Tops or Lefts, even if it is for other controls)?
In that case, would you be able to post the relevant code?

Dabas
SOLUTION
Avatar of JMoon5FTM
JMoon5FTM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of santosh26676
santosh26676

If you place a container object (either picturebox or frame control) and size it the same as of the tab page. Place the grid control within the container object. This way in load event you will get the correct position of the grid.

hope this helps!!!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The coordinates of the grid will always be the same. If you move the picture box then the coordinates of the picturebox will change but the coordinates of the grid will not change.
They will be the same, but only compared to picture box coordinates.

grid's absolute coordinates (its position on screen or form) are changed as tab buttons are switched, bacouse you have to calculate picture coordinates also.
Since picture coordinates change, so will grid's absolute coordinates.
Avatar of baudspeed

ASKER

Thanks Guys, Everyones answers were good. I wish i had more points to dole out. But i think i divided them the best way i could.

The tab dialog box must have been a third party object that microsoft bought off a company or something. Its just such a kludgy way of dealing with object controls.

Thanks Again
Thanks!
Kludgy?  Certainly, but I doubt Microsoft could have done better.  You can't actually hide or show a control without changing its Visible property.  The TabbedDialog's developers probably correctly figured that most of us would want the Visible property setting maintained across page navigations, so they had to come up with another way of hiding controls.

Glad I could be of assistance. :)
Valid point. I hadnt considered that flipping the visible/invisible flag would lose its original state.
Oh well. Im sure .net does things better
Have a good weekend guys
Well, I think one of the reasons why they have done it this way is becouse controls can't be hidden in design view (when app is not running).
If it would work using "visible" property, then we would have many controls overlaping on the same place in design view, which is not very "programmer - friendly"

Off course, they could have done it by changing the position in design view, and changing "visible" property during run-time. This way controls would allways stay in their place, but unfortunately, this is not the case.

Maybe some of Tabbed Dialog developers will read this thread, and make another "smarter" version of this control. :-)

Cheers!