简体   繁体   English

C#Windows窗体:如何将backgroundimage大小匹配到窗体大小

[英]c# windows form: How to match backgroundimage size to form size

I am trying to match form size to the form background image size. 我正在尝试将表单大小与表单背景图像大小进行匹配。 The code: 编码:

var newImage = PB_DEPTH.Image;
var newForm = new Form();

newForm.BackgroundImage = newImage;
newForm.Width = this.depthFrameDescription.Width;
newForm.Height = this.depthFrameDescription.Height;
newForm.Show();

Problem is new form still crops part of the image. 问题是新表格仍会裁剪图像的一部分。 I imagine that this is due to the top menu strip containing the close, minimize, maximize icons. 我想这是由于顶部菜单栏包含关闭,最小化和最大化图标。

Is there any way to get the size of that strip instead of applying constant offset values? 有什么方法可以获取该条带的尺寸,而不是应用恒定的偏移值吗?

Or better yet a way to properly resize a form to match backgroundimage dimensions. 或更好的方法是正确调整表单大小以匹配backgroundimage尺寸。

尝试将newForm.ClientSize设置为背景图像的大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM