Here is what I did as a simple test ...
I added a simple wrapper class to change what happens when ToString is called (I just wanted to see the name specified in the combo box)
private class ScreenObj
{
public Screen screen = null;
public ScreenObj(Screen scr)
{
screen = scr;
}
public override string ToString()
{
return screen.DeviceName;
}
}
In the form load event, I added the following:
foreach(Screen screen in Screen.AllScreens)
{
cboScreens.Items.Add(new ScreenObj(screen));
}
And for the selected index change event in the combo box, I had this:
private void cboScreens_SelectedIndexChanged(object sender, EventArgs e)
{
object o = cboScreens.SelectedItem;
if(null == o)
return;
ScreenObj scrObj = o as ScreenObj;
if(null == scrObj)
return;
Point p = new Point();
p.X = scrObj.screen.WorkingArea.Left;
p.Y = scrObj.screen.WorkingArea.Top;
this.Location = p;
}
Moved the shape to the upper left corner of each of my screens.
source
share