# VC# sample code request

**URL:** <https://tech-community.robotics.abb.com/t/vc-sample-code-request/1223>\
**Category:** RobotStudio\
**Created:** [May 18, 2007, 9:29pm UTC](https://tech-community.robotics.abb.com/t/vc-sample-code-request/1223 "2007-05-18T21:29:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhanscom](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@bhanscom](https://tech-community.robotics.abb.com/u/bhanscom)\
**Post date:** [May 18, 2007, 9:29pm UTC](https://tech-community.robotics.abb.com/t/vc-sample-code-request/1223/1 "2007-05-18T21:29:37Z")

</div>

Hi,

From Visual C#, not VSTA, how can I get to the selection modes in order to set a particular level when a certain event happens. i.e. Clicking in a text window will set the selection level to ‘part’ or ‘surface’, etc.

Thanks

---

<div class="post-metadata">

**Author:** ![PerSvensson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/persvensson/32/1040_2.png) [@PerSvensson](https://tech-community.robotics.abb.com/u/PerSvensson)\
**Post date:** [May 19, 2007, 3:51pm UTC](https://tech-community.robotics.abb.com/t/vc-sample-code-request/1223/2 "2007-05-19T15:51:58Z")

</div>

Hi  
You could do something like this

public static void SetSelectionMode(SelectionModes mode)

{

foreach (Window w in UIEnvironment.Windows)

{

if ((w is DocumentWindow) && w.Control is GraphicControl)

{

GraphicControl gc = w.Control as GraphicControl;

if (gc != null)

gc.Picker.SelectionMode = mode;

}

}

}

and then just call it with the selectionmode you want for example

SetSelectionMode(SelectionModes.Curve);

You need to add some namespaces as well at least

using ABB.Robotics.RobotStudio.Stations.Forms;  
using ABB.Robotics.RobotStudio.Environment;

---

<div class="post-metadata">

**Author:** ![bhanscom](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@bhanscom](https://tech-community.robotics.abb.com/u/bhanscom)\
**Post date:** [May 21, 2007, 1:57pm UTC](https://tech-community.robotics.abb.com/t/vc-sample-code-request/1223/3 "2007-05-21T13:57:36Z")

</div>

THanks
