Solved

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

Posted on 2004-03-30
12
522 Views
Last Modified: 2013-12-26
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+
0
Comment
Question by:baudspeed
  • 5
  • 2
  • 2
  • +2
12 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 10719418
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
0
 
LVL 5

Assisted Solution

by:JMoon5FTM
JMoon5FTM earned 100 total points
ID: 10720245
Are you using the TabbedDialog control for your tab sheet?

If so, you need to set the Tab property to the tab the flexgrid sits on.  No control on your form will return accurate positioning information unless its tab is active.
0
 
LVL 11

Accepted Solution

by:
dbrckovi earned 400 total points
ID: 10721516
I agree with JMoon5FTM.

Tabbed dialog control (SSTab), and similar, can have several "pages" of controls, and it can display one page at a time, based on the tab button which is active.
At first it seems that all controls are placed on the same place and that Tab control is making everything that does not belong to current page invisible.
This is not true. When you place something to first page (Tab1), and then press Tab2, everything that belongs to Tab1 is moved to the left ( .Left values are negative )
Now if you place something to tab2, and switch back to tab1, everything that was on tab2, is moved left, and controls that belong to tab1 are moved back to their original positions.

Place SSTab control on a form
Place Textbox to Tab0
Place Label to Tab1
Place Picturebox to Tab2
Place Command Button outside SSTab

-----------------------------------------
Private Sub Command1_Click()
    Label1.Left = 0
    Text1.Left = 0
    Picture1.Left = 0
End Sub
-----------------------------------------
Pressing the command button will make all 3 controls visible.
0
 
LVL 3

Expert Comment

by:santosh26676
ID: 10721958
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!!!
0
 
LVL 11

Assisted Solution

by:dbrckovi
dbrckovi earned 400 total points
ID: 10722374
santosh26676.

That way you will get grid's coordinates inside its container correct, but I think that baudspeed wants to get grid's absolute coordinates ( exact on-screen position where grid is placed )
That would mean that one should add containers coordinates as well.
For example: GridAbsoluteLeft = Form1.Left ( + FormBorderWidth) + SSTab.Left + Picture.Left + Grid.Left

Since Picture box (grid's container) is moved as Tab buttons switch, the value won't be allways the same.
The only way to do this right is, as JMoon5FTM suggested: - to activate the correct tab and then get the coordinates.
0
 
LVL 3

Expert Comment

by:santosh26676
ID: 10722547
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.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 11

Expert Comment

by:dbrckovi
ID: 10723323
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.
0
 

Author Comment

by:baudspeed
ID: 10724878
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
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 10730299
Thanks!
0
 
LVL 5

Expert Comment

by:JMoon5FTM
ID: 10732412
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. :)
0
 

Author Comment

by:baudspeed
ID: 10733576
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
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 10738917
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!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now