2

Is there any easy way to run an application created in C# on Visual Studio 2005 on any different PC, regardless of its screen resolution?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
mahesh
  • 1,370
  • 9
  • 36
  • 61

1 Answers1

5

Screen resolution?

Windows Forms in .NET 2.0 has some mechanisms for dealing with different DPI and it has a better layout system than in .NET 1.1. In general, use layout panels like FlowLayoutPanel, TableLayoutPanel, etc instead of fixing your controls at X/Y coordinates and you'll have a much easier time dealing with different window sizes.

If you can use WPF which I don't recall being applicable to Visual Studio 2005, then you have much more options for resolution independence. The DPI issue goes away and WPF has features such as ViewBox that lets you scale an entire window or control uniformly.

Josh
  • 68,005
  • 14
  • 144
  • 156
  • I guess I didn't think of screen resolution - +1 for guessing that. I stuck with answering the "on any PC" since the question was a bit unclear. – David Jan 04 '11 at 04:13
  • 1
    +1 Don't forget about setting your form's [`AutoScaleMode` property](http://msdn.microsoft.com/en-us/library/system.windows.forms.containercontrol.autoscalemode.aspx) to either "DPI" or "Font", depending on which works best in your scenario. See also MSDN's comprehensive article on [Automatic Scaling in Windows Forms](http://msdn.microsoft.com/en-us/library/ms229605.aspx). – Cody Gray - on strike Jan 04 '11 at 04:27
  • Indeed, but one should not rely solely on AutoScaleMode because it rarely works as magically as promised. If you use layout panels and AutoSize where applicable, you'll generally be in good shape. Oh yeah and never design Windows Forms at anything other than 96 DPI on your machine! – Josh Jan 04 '11 at 04:30
  • WPF is for .Net 3.0 Framework supported while as VS-2005 has .Net 2.0 Framework So I think it's wasting of time about thinking WPF in VS-2005. – mahesh Jan 04 '11 at 04:34
  • Other than that brief paragraph mentioning WPF at the end, the rest of the answer and all the comments are about Windows Forms. – Josh Jan 04 '11 at 04:36