Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

c# Windows Form location sometimes ends off off screen

$
0
0

I am having an issue where in a small number of users, occasionally a windows form does not display on the screen at the last saved coordinates. There doesn't seem to be any pattern as to how this happens but it seems most of the time it is on systems with multiple monitors. The Form.Load code is like this:

publicvoidForm4_Load(object sender,EventArgs e){int formXPos =Properties.Settings.Default.K3FormStartPositionX;int formYPos =Properties.Settings.Default.K3FormStartPositionY;Point p =newPoint(formXPos, formYPos);this.Location= p;}

The form.closing code is:

if(this.WindowState==FormWindowState.Minimized){this.WindowState=FormWindowState.Normal;}Properties.Settings.Default.K3FormStartPositionX =Location.X;Properties.Settings.Default.K3FormStartPositionY =Location.Y;Properties.Settings.Default.Save();

Only a very few users "sometimes" have an issue. When it happens, the Location.X and Location.Y properties are set to -32000. So, since I could not find the issue, when the form loads and if Location.X or Location.Y is < 0 I would set the position at 10,10 to get around the bug. Unfortunately, I now have a couple of users where the form is now always going to 10,10 . Again a very few users and not the same as the others. I cannot reproduce this at all. I have tested on Win7, Win8, on systems with multiple monitors and I never have an issue. Does anyone know what might be going on? Thanks


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>