Windows Form Application Size Issue
-
Hi,I developed a application which contains some panels.my desktop screen resolution is 1280X768.When the same application runs in some other system whose desktop resolution is 1024X768 it is showing in another way. Eventhough I changed the Form and its UI elements size programmatically in the form constructor like below there is no change in their dimensions. int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeigth = Screen.PrimaryScreen.Bounds.Height; this.Size = new Size(screenWidth, screenHeigth); this.Invalidate(); this.Update(); InitializeComponent(); this.pnlSi.Size = new Size(screenWidth, screenHeigth); this.pnlSi.Invalidate(); this.pnlSi.Update(); this.pnldjt.Size = new Size(screenWidth, screenHeigth); this.pnldjt.Invalidate(); this.pnldjt.Update(); Anybody please inform me how to resolve this issue?I mean changing the form and its UI elements programmatically at run time as per application running system desktop resolution?Thanks in advance.
-
Hi,I developed a application which contains some panels.my desktop screen resolution is 1280X768.When the same application runs in some other system whose desktop resolution is 1024X768 it is showing in another way. Eventhough I changed the Form and its UI elements size programmatically in the form constructor like below there is no change in their dimensions. int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeigth = Screen.PrimaryScreen.Bounds.Height; this.Size = new Size(screenWidth, screenHeigth); this.Invalidate(); this.Update(); InitializeComponent(); this.pnlSi.Size = new Size(screenWidth, screenHeigth); this.pnlSi.Invalidate(); this.pnlSi.Update(); this.pnldjt.Size = new Size(screenWidth, screenHeigth); this.pnldjt.Invalidate(); this.pnldjt.Update(); Anybody please inform me how to resolve this issue?I mean changing the form and its UI elements programmatically at run time as per application running system desktop resolution?Thanks in advance.
How is it not showing in the correct way? what is the actual issue. All I can see is that you are setting 2 panels and the form to the same size at runtime
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
-
Hi,I developed a application which contains some panels.my desktop screen resolution is 1280X768.When the same application runs in some other system whose desktop resolution is 1024X768 it is showing in another way. Eventhough I changed the Form and its UI elements size programmatically in the form constructor like below there is no change in their dimensions. int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeigth = Screen.PrimaryScreen.Bounds.Height; this.Size = new Size(screenWidth, screenHeigth); this.Invalidate(); this.Update(); InitializeComponent(); this.pnlSi.Size = new Size(screenWidth, screenHeigth); this.pnlSi.Invalidate(); this.pnlSi.Update(); this.pnldjt.Size = new Size(screenWidth, screenHeigth); this.pnldjt.Invalidate(); this.pnldjt.Update(); Anybody please inform me how to resolve this issue?I mean changing the form and its UI elements programmatically at run time as per application running system desktop resolution?Thanks in advance.
InitializeComponent();
should be the first statement after the constructor. Do you know what happens in that function? A lot of values, among them positions and sizes, are set. I'd rather use athis.WindowState = FormWindowState.Maximized;
in theForm_Shown
event. If you want to re-order the elements, you can additionally subscribe to aResize
event, and do that there. -
Hi,I developed a application which contains some panels.my desktop screen resolution is 1280X768.When the same application runs in some other system whose desktop resolution is 1024X768 it is showing in another way. Eventhough I changed the Form and its UI elements size programmatically in the form constructor like below there is no change in their dimensions. int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeigth = Screen.PrimaryScreen.Bounds.Height; this.Size = new Size(screenWidth, screenHeigth); this.Invalidate(); this.Update(); InitializeComponent(); this.pnlSi.Size = new Size(screenWidth, screenHeigth); this.pnlSi.Invalidate(); this.pnlSi.Update(); this.pnldjt.Size = new Size(screenWidth, screenHeigth); this.pnldjt.Invalidate(); this.pnldjt.Update(); Anybody please inform me how to resolve this issue?I mean changing the form and its UI elements programmatically at run time as per application running system desktop resolution?Thanks in advance.
I believe Bernard Hiller gave you the correct answer (I voted his answer #5, naturally): move the call to InitializeComponent() to before your Form and Panel adjustment code. An edge-case hypothesis could be: the monitors have different aspect ratios, but I doubt that. best, Bill
"Everything we call real is made of things that cannot be regarded as real." Niels Bohr