# RobotStudio API - ToolWindow DockStyle

**URL:** https://tech-community.robotics.abb.com/t/robotstudio-api-toolwindow-dockstyle/1679
**Category:** RobotStudio
**Created:** [February 11, 2008, 3:47pm UTC](https://tech-community.robotics.abb.com/t/robotstudio-api-toolwindow-dockstyle/1679 "2008-02-11T15:47:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@neil](https://tech-community.robotics.abb.com/u/neil)
#### Post date: [February 11, 2008, 3:47pm UTC](https://tech-community.robotics.abb.com/t/robotstudio-api-toolwindow-dockstyle/1679/1 "2008-02-11T15:47:28Z")

</div>

Hi,

Just wondering if it is possible to have a “floating” tool window in RobotStudio. The tool window controls are designed through a UserControl. I have tried the following code, using VS 2005:

public static void AddinMain()  
{  
ToolWindow tw = new ToolWindow();’  
UserControl1 uc = new UserControl1()  
tw.Control = uc;

UIEnvironment.Windows.AddDocked(tw, DockStyle.None);  
}

When RobotStudio starts up the following message appears in the RS ouput window:

“Value does not fall within the expected range”

and the addin does not load. The same happens if I use DockStyle.Fill

Changing the DockStyle property to “Dockstyle.Right”, the add in loads up with no error.

Thanks in advance,  
Neil

---

<div class="post-metadata">

### Author: ![Niklas\_Skoglund](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Niklas\_Skoglund](https://tech-community.robotics.abb.com/u/Niklas_Skoglund)
#### Post date: [February 12, 2008, 1:17pm UTC](https://tech-community.robotics.abb.com/t/robotstudio-api-toolwindow-dockstyle/1679/2 "2008-02-12T13:17:52Z")

</div>

Hi Neil,

if you want to have a floating ToolWindow just call Windows.Add instead:

public static void AddinMain()  
{  
ToolWindow tw = new ToolWindow();  
tw.Caption = “MyFloatingToolwindow”;  
Button b = new Button();  
b.Text = “ClickMe”;  
b.Size = new Size(100, 100);  
tw.Control = b; &nbs p;  
UIEnvironment.Windows.Add(tw);  
}

The reason you got an exception was that the method Windows.AddDocked() does not support DockStyle.None, because it means that the window is not docked. I will update the exception message text to be more descriptive.

---

<div class="post-metadata">

### Author: ![Bernd](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@Bernd](https://tech-community.robotics.abb.com/u/Bernd)
#### Post date: [April 15, 2009, 1:36pm UTC](https://tech-community.robotics.abb.com/t/robotstudio-api-toolwindow-dockstyle/1679/3 "2009-04-15T13:36:10Z")

</div>

I tried this example and after starting my Add-In a message box pops up with the information “RobotStudio has encountered a user-defined breakpoint.”

![](http://forums.robotstudio.com/webwiz/2887/error.JPG)

After clicking “Close” the Add-In is loaded and the toolWindow is visible.

The Debugger stops at the last line of the code snippet (UIEnvironment.Windows.Add(tw)😉

Does anybody know how to fix that problem?

Thank you,  
Bernd
