Kiet Duong
Kiet Duong

Reputation: 43

How can I hide winform controls from second monitor?

I have my winform app displayed simultaneously on dual screens: one on my laptop, one on my tv (connected via cable). My app has a listview and a richtextbox. By default, the whole app displays on my laptop's screen, and it's ok. The problem is, how can I display only the richtextbox on my tv's screen , not the listview.

Upvotes: 2

Views: 231

Answers (1)

Mark Hall
Mark Hall

Reputation: 54532

Something like this should work for you. It uses the Screen.AllScreens collection, each index is one of your monitors. Check if the location of your application is on your TV and write the appropiate code to hide what you need to. You could put this in the LocationChanged event.

if(Screen.AllScreens[0].Bounds.Contains(this.Bounds))  // 0 is the primary monitor
{                                                      // use the index that equates to your TV
    // Hide your listbox here.
}

Upvotes: 2

Related Questions