Usuário com melhor resposta
Alterar em modo de execução width e height de forms mdi.

Pergunta
-
Boa pessoal.
Estou com um projeto em windowsforms que o cliente só usava monitores na resolução 1366 x 768, mas agora estão mudando algumas maquinas para monitores de 1920x1080.
o form principal esta setando como maximized, os forms mdi foram setados para ocupar uma área de 1308x695 dai ficava tudo certinho.
Agora com essa mudança, estou tendo que alterar o projeto, pra não dar a solução mais bacalhau que seria criar uma copia do projeto e alterar tudo pra resolução de 1920 (rsrsrsrsrs) resolvi utilizar o screen para pegar a resolução do monitor principal. e setar o form e o panel ( este panel esta ancorando como top e bottom) , mas quando altero o panel para a resolução de 1920 todos os componentes ficam zoneados. Alguém tem alguma solução na qual eu não tenha que ancorar esses componentes dentro do panel ?
Respostas
-
Alterei o Point e size e fiz a vinculação no panel.
Consegui acertar assim.
Ainda estou tentando descobrir como alterar o tamanho da fonte de todo o panel, pois individualmente ja consegui, mas vai dar um trabalho dos infernos fazer um a um.
afim de ajudar quem tiver a mesma duvida, posto o codigo.
no load do form incluir Screen srn = Screen.PrimaryScreen; int theight = srn.Bounds.Width; int tWidth = srn.Bounds.Height; if (theight == 1366) { Point pt = new Point(12, 12); this.Width = 1308; panel1.Width = 1280; panel1.Location = pt; this.Height = 695; panel1.Height = 671; } else if (theight == 1680) { this.Width = 1622; this.Height = 977; } else if (theight == 1920) { Point pt = new Point(100, 15); Size sz = new Size(45, 45); panel1.Location = pt; this.Width = 1920; panel1.Width = 1480; this.Height = 1007; panel1.Height = 871; panel1.Font = new Font("Verdana", 12, FontStyle.Regular); groupBox1.Font = new Font("Verdana", 12, FontStyle.Regular); label1.Font = new Font("Verdana", 11, FontStyle.Regular); label10.Font = new Font("Verdana", 11, FontStyle.Regular); label11.Font = new Font("Verdana", 11, FontStyle.Regular); label12.Font = new Font("Verdana", 11, FontStyle.Regular); label13.Font = new Font("Verdana", 11, FontStyle.Regular); label14.Font = new Font("Verdana", 11, FontStyle.Regular); txbTotal.Size = sz; }
att Wsti.
- Marcado como Resposta Wsti terça-feira, 12 de janeiro de 2016 20:27
Todas as Respostas
-
public MainView() { InitializeComponent(); // posicao inicial definida manualmente Rectangle screen = Screen.PrimaryScreen.WorkingArea; int w = Width >= screen.Width ? screen.Width : (screen.Width + Width) / 2; int h = Height >= screen.Height ? screen.Height : (screen.Height + Height) / 2; this.Location = new Point((screen.Width - w) / 2, (screen.Height - h) / 2); this.Size = new Size(w, h); }
(fonte: http://stackoverflow.com/questions/5074917/how-to-fit-windows-form-to-any-screen-resolution)
Por favor, lembre-se de “Marcar como Resposta” as respostas que resolveram o seu problema. Essa é uma maneira comum de reconhecer aqueles que o ajudaram e fazer com que seja mais fácil para os outros visitantes encontrarem a resolução mais tarde.- Editado Erick WendelMVP terça-feira, 12 de janeiro de 2016 13:33
- Sugerido como Resposta Erick WendelMVP terça-feira, 12 de janeiro de 2016 13:33
-
Oi Erick, a resolução eu tenho, minha questão é a ancoragem dos componentes no panel, pois quando altero para a resolução de 1920 os textbox, labels e etc ficam todos zuados.
Att, wsti.Screen srn = Screen.PrimaryScreen; int theight = srn.Bounds.Width; int tWidth = srn.Bounds.Height; if (theight == 1366) { Point pt = new Point(12, 12); this.Width = 1308; panel1.Width = 1280; panel1.Location = pt; this.Height = 695; panel1.Height = 671; }
else if (theight == 1920)
{
this.Width = 1920;
panel1.Width = 1480;
this.Height = 1007;
panel1.Height = 871;
} -
Alterei o Point e size e fiz a vinculação no panel.
Consegui acertar assim.
Ainda estou tentando descobrir como alterar o tamanho da fonte de todo o panel, pois individualmente ja consegui, mas vai dar um trabalho dos infernos fazer um a um.
afim de ajudar quem tiver a mesma duvida, posto o codigo.
no load do form incluir Screen srn = Screen.PrimaryScreen; int theight = srn.Bounds.Width; int tWidth = srn.Bounds.Height; if (theight == 1366) { Point pt = new Point(12, 12); this.Width = 1308; panel1.Width = 1280; panel1.Location = pt; this.Height = 695; panel1.Height = 671; } else if (theight == 1680) { this.Width = 1622; this.Height = 977; } else if (theight == 1920) { Point pt = new Point(100, 15); Size sz = new Size(45, 45); panel1.Location = pt; this.Width = 1920; panel1.Width = 1480; this.Height = 1007; panel1.Height = 871; panel1.Font = new Font("Verdana", 12, FontStyle.Regular); groupBox1.Font = new Font("Verdana", 12, FontStyle.Regular); label1.Font = new Font("Verdana", 11, FontStyle.Regular); label10.Font = new Font("Verdana", 11, FontStyle.Regular); label11.Font = new Font("Verdana", 11, FontStyle.Regular); label12.Font = new Font("Verdana", 11, FontStyle.Regular); label13.Font = new Font("Verdana", 11, FontStyle.Regular); label14.Font = new Font("Verdana", 11, FontStyle.Regular); txbTotal.Size = sz; }
att Wsti.
- Marcado como Resposta Wsti terça-feira, 12 de janeiro de 2016 20:27