SCSF Modal windowworkspace resizing problem

Topics: CAB & Smart Client Software Factory
Sep 19, 2007 at 8:48 AM
I have a smart part that is displayed in a resizeable window workspace, the windowsmartpartinfo is set to be modal. However when the window is resized the smart part does not resize occordingly. This works when in a tab workspace for example.

Is there a certain set of properties that need to be set in order for this to work?

Sep 20, 2007 at 2:38 PM

What you must to do for your SmartPart resize occordingly, is to set its Dock property in the constructor of the following way:

// Constructor.
public ExampleView()
    this.Dock = DockStyle.Fill;
Also you will have to set the property Anchor accordingly in all the controls (for example Left, Right). This you can do it from the Properties window from the Design.

Please let me know if this helps!

Mariano Converti
Sep 20, 2007 at 3:12 PM
Edited Sep 20, 2007 at 3:12 PM
Thanks for the reply and suggestion.

I was trying to avoid setting the dock inside the smart part. As when the smart part is shown in other workspaces such as the tabworkspace the dock works automatically. I have set all the anchors on the controls

I would like the window workspace to work the same. Other smart part developers would not know to set the dock for window workspaces, so would like to do it in the infrastructure.

I have got it to do it like this by modifying the windowworkspace like this.

protected new Form GetOrCreateForm(Control control)
bool resizeRequired = !Windows.ContainsKey(control);
Form form = base.GetOrCreateForm(control);
form.ShowInTaskbar = (_owner == null);
if (resizeRequired)
form.ClientSize = control.Size;

// fix to enable resizing dialogs
control.Dock = DockStyle.Fill;
// fix to stop the dialog from being made too small.
form.MinimumSize = control.Size;

return form;

I'm not sure if there are any nasty side effects yet.
May 16, 2008 at 2:47 AM
i tried setting the minimum width and height in designer. however, i still can resize the form to be smaller than it is. What did I miss out?