如何在MDI父级的右侧角设置图像?
我正在使用 Windows 窗体项目。在我的 MDI 父表格中,我想在右上角显示我的公司徽标。所以我拖动了一个图片框并设置了图像。
但我没有成功我的要求,图像位置不正确。我也尝试过填充。 Dock 正在将我的图像高度增加到完整的高度。所以它也对我没有帮助。
运行解决方案之前。 (我希望这是一个运行时间)..
解决方案运行时。 (右侧不需要的空间)
并且 MDI 表单在运行时最大化。在下面代码的帮助下。
this.WindowState = FormWindowState.Maximized;
I am using Windows Form project. In my MDI Parent Form that I want to show my company logo at the right side corner. So I have drag a picturebox and set the image.
But I am not success my requirement, The image not in correct position. I have tried padding also. Dock is increase my image height to full form height. So Its also not help me.
Before Running the Solution. (I want this as a run time)..
At the Time of Solution Running. (Unwanted Space in Right side)
And MDI Form is Maximized at running time. with the help of below code.
this.WindowState = FormWindowState.Maximized;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须将图片框的 Anchor 属性设置为 Top, Right,默认设置为
Top, Left
You will have to set Anchor property of picturebox to Top, Right by default its set to
Top, Left
当您开始创建 MDI 客户端窗口时,您很快就会发现这是行不通的。图片框始终位于客户端窗口的顶部。需要在 MDI 客户端窗口(屏幕截图中的深灰色窗口)中绘制图像。这需要相当多的不寻常代码,您必须获得对该控件的引用,以便您可以为其实现自己的 Paint 事件。您还需要注意窗口大小会发生变化,以便您可以在新位置重新绘制图像。您必须对通常看到的闪烁采取一些措施。让您的代码看起来与此类似:
This isn't going to work, you'll discover soon when you start creating MDI client windows. The picture box is always on top of the client windows. What is required is drawing the image in the MDI client window, the dark gray window in your screenshots. That takes a fair amount of unusual code, you have to get a reference to that control so you can implement your own Paint event for it. You also need to be aware that the window size changes so your can repaint the image in the new location. And you have to do something about the flicker you normally see. Make your code look similar to this:
将图片框放入容器中,然后先将容器停靠。然后仅容器停靠到右侧。并将图像放入图片框。
Put picture box in to a container and Dock the Container first. Then Container Only Dock to right. And put and Image to picture box.