[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-03-30
12
Medium Priority
?
533 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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 1600 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1600 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
 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

649 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