# Rectangle click event

**URL:** <https://forum.commonvisionblox.com/t/rectangle-click-event/1543>\
**Category:** Programming Questions\
**Created:** [November 10, 2021, 2:30pm UTC](https://forum.commonvisionblox.com/t/rectangle-click-event/1543 "2021-11-10T14:30:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![George](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@George](https://forum.commonvisionblox.com/u/George)\
**Post date:** [November 10, 2021, 2:30pm UTC](https://forum.commonvisionblox.com/t/rectangle-click-event/1543/1 "2021-11-10T14:30:50Z")

</div>

Hello,  
I have 35 rectangles like this one over one image on one display:

```auto
Display1.Overlays.Add(new RectOverlay("0", false, Color.Yellow, false, false, new Rect(new Point2D(0, 0), new Size2D(xLeft1, yDisplay1))));

```

I am trying to click on one of them and show that rectangle only and its image portion on other display.  
The only tutorial with some rectangle click event is Image Manager\[Cvb.net](http://Cvb.net)\Display but unfortunately it didn’t respond my question.  
Any suggestion?  
Thank you very much

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [November 11, 2021, 11:09am UTC](https://forum.commonvisionblox.com/t/rectangle-click-event/1543/2 "2021-11-11T11:09:24Z")

</div>

Hi @George

the first idea that comes to my mind is to change the Overlays collection and create a new one that only consists of the one clicked rect.

Keep all the other ones in a backingstore for when the user wants to display all the overlays again, you can simply call Overlays = new ObservableCollection(overlaysBackup)

Second idea (probably the better one):  
Set the IsVisible or IsEnabled property of all Overlays to false that are not the desired overlay.

Changes in the selected item or the whole Overlays collection will be handled as described here:

[https://forum.commonvisionblox.com/t/wpf-mvvm-cvb-display-with-overlays-fixed-and-resizeble/956](https://forum.commonvisionblox.com/t/wpf-mvvm-cvb-display-with-overlays-fixed-and-resizeble/956)

Cheers  
Chris

---

<div class="post-metadata">

**Author:** ![George](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@George](https://forum.commonvisionblox.com/u/George)\
**Post date:** [November 11, 2021, 11:20am UTC](https://forum.commonvisionblox.com/t/rectangle-click-event/1543/3 "2021-11-11T11:20:04Z")

</div>

![Screenshot 2021-11-11 111220](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/4b2bdebcc8248660c511759a411085ea3aa82e1c.jpeg)  
Rectangles have to be visible all the time, Chris.  
So I am not sure how to show a selected rectangle on another display by clicking on it or by calling it.  
I am going to read the info you suggested, thank you Chris.

---

<div class="post-metadata">

**Author:** ![George](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@George](https://forum.commonvisionblox.com/u/George)\
**Post date:** [November 11, 2021, 11:59am UTC](https://forum.commonvisionblox.com/t/rectangle-click-event/1543/4 "2021-11-11T11:59:19Z")

</div>

I’ve read all the info (by the way I am using Forms, not WPF) and not a single clue about how to create a subimage from one of my ROI to showing it on another display.

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [November 11, 2021, 12:15pm UTC](https://forum.commonvisionblox.com/t/rectangle-click-event/1543/5 "2021-11-11T12:15:13Z")

</div>

Hi Geroge,

basically the subimage is Created using the [Map()](https://help.commonvisionblox.com/NextGen/14.0/cvbnet/dd/d4d/class_stemmer_1_1_cvb_1_1_image.html#a3a6c64172bc258269ce1ea1c57328604) function.
