How do I center my diagram

Hi, using GoDiagram for .NET for first time. Have placed some GoTextNodes on a Document and added links. Then applied a Tree Layout and it looks great. However my diagrams have different sizes and I want them to always be automatically centered in the view. I have my view in a panel with DockStyle = Fill. I have been looking at
_view.DocPosition = new PointF(
_view.Width / 2 - _view.DocExtent.Width / 2,
_view.Height / 2 - _view.DocExtent.Height / 2

but my _view and DocExtent alwasys seen to be about the same even when the diagram is small. Any help appreciated ...

That’s the right idea, except that setting GoView.DocPosition calls GoView.LimitDocPosition to make sure the desired point is within the range of the document’s extent, as seen by the view.

Among various reasons, that's to make sure the document isn't "scrolled" to somewhere the scrollbars don't allow. (The scrollbars depend on the values of GoView.DocPosition, GoView.DocScale, GoView.DocumentTopLeft, and GoView.DocumentSize, as well as the view's DisplayRectangle.)
So the easiest solution is to make the document's TopLeft and Size properties large enough to cover the area you want, before you call GoView.RescaleWithCenter. You can pass the current GoView.DocScale as the first argument. This method will set the GoView.DocPosition.