Hello,
Are you overriding OnSizeChanged or OnCreateControl in your GoView class?
I am not. I am just putting the nodes and links directly into the GoView.
(via email, the answer to that was no)
The GoView is docked (Fill) below a windows toolbar. These 2 controls make up 1 larger control which is docked (Fill) in a panel.
But if you resize the window after startup, the scrollbar snaps to the right location, do I understand correctly?
Yes, that is correct. Even if I move the splitter bar to the right the horizontal bar snaps back to the bottom.
So, you have a user control that includes a GoView and a toolbar? Does the height of the GoView in the definition of the user control happen to match the height of the spot where the scroll bar is ending up?
It might be close, but not exact. My user control is 248, 153 in the designer. I think when you look at my screenshot you will see that it is bigger than that.
Well, it ought to “just work”, but maybe something about being a control inside a user control is keeping the GoView from getting the resize event at the right time during startup. Where are you trying to do the LayoutScrollbars? Can you set a breakpoint there and see what the GoView size is?
I am calling LayoutScrollbars after I do all the populating of the GoView.
The code inside the GoViewPopulator.Initialize looks like this…
view.BeginUpdate(); _displayHorizontal = displayHorizontal; Initialize(collection, view); view.EndUpdate(); The Initialize adds the nodes, then adds the links then performs a layout on all the nodes to move them off of each other. Originally they are all added at 0,0The first time I hit the LayoutScrollbars
Even trying to manually assign the height of the scrollbar does not work. Could there be some kind of reference problem? I am passing the GoView around…
Could you try removing all “artificial” adjustments and initialization code? I mean all those calls to methods that have “Update” or “Layout” in their names, both for GoView as well as standard Windows Forms controls. In as much as possible, just have the code that the Visual Studio designer created, and as little else as possible.
If there is still a problem, try putting the code to initialize your view’s document into a separate button or other command that the user invokes after the whole window is visible. If this fixes the problem, then you must be initializing the view too early. Try doing it when the Form is loaded.
If you still have a problem after this second step, I would guess that you didn’t clean up all of the initialization code correctly from the first step.
I tried your sugestion of the button to display the view. This works. However, when I look in my code I am doing InitializeComponent way before I ever try to populate the document. So the view is completely created at this point correct? Is it maybe a problem because all the parent forms or controls are not done painting?
Question, just for my understanding because I have fixed the problem but it seems…well odd…
LayerToSelect = layerToSelect;
DisplayNodes(layerToSelect, GoViewPopulator.DisplayHorizontal);
}
New code:
public void Initialize(string layerToSelect) { SetUpGoViewPopulator(); SetupToolbar();LayerToSelect = layerToSelect;
// This forces the Enter event to fire.
// This event will populate the Nodes in the view.
this.Focus();
}
well, it looks like you’ve set it up so that a Windows event is the final initialization. The event gets delivered after all the startup code has run and the app has returned to the “idle loop”. So, I don’t think this is really different than the “click the button” test case.
I do not think it is any different either, other than the user does not have to click on something which is a requirement for me.
The Windows Program main loop isn’t as apparent in .NET applications as it was in old style Windows programming. The _Enter event isn’t delivered when you call this.Focus. It gets queued up until “new Form()” code is done executing.
Thanks. It does make sense to me. The confusing part is the new Form() code has been called and executed minutes before I try to display the nodes. I am just confused on how I could be getting stuck in there. I do realize that is not your concern.