Hi,
I am building a custom windows forms designer and I would like to enable the "Layout" toolbar for it so that I can use Align commands (and also TabOrder command). VS does ask the designer if designer supports these commands, but I do not know what to do once the user activates the command.
My designer uses existing DesignSurface class for design. Does the existing DesignSurface support Align and TabOrder commands out of the box If so, how can I turn them on
Thanks.

Using Layout toolbar in custom windows forms designer
ravensensei
Hi everybody,
I have found the solution. The solution is to use System.Windows.Forms.Design.TabOrder class. This class is internal so you must use reflection in order to instantiate it. Here is a sample on how to do it:
IDesignerHost _host =....;
/// <summary>
/// Enables/Disables visual TabOrder on the view.
/// </summary>
internal override void DoVisualTabOrder() {
Assembly designAssembly = Assembly.Load("System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
Type tabOrderType = designAssembly.GetType("System.Windows.Forms.Design.TabOrder");
if (_tabOrder == null) {
_tabOrder = Activator.CreateInstance(tabOrderType, new object[] { _host });
} else {
DisposeTabOrder();
}
}
private object _tabOrder = null;
/// <summary>
/// Disposes the tab order.
/// </summary>
private void DisposeTabOrder() {
if (_tabOrder == null)
return;
Assembly designAssembly = Assembly.Load("System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
Type tabOrderType = designAssembly.GetType("System.Windows.Forms.Design.TabOrder");
tabOrderType.InvokeMember("Dispose", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, _tabOrder, new object[] { true });
_tabOrder = null;
}
dalieu
Thanks