我将Windows窗体的BackgroundImage设置为200 x 200图像.表格是500 x 500.我希望图像锚定在表单的右下角.但是,我唯一可用的选项是BackgroundImageLayout属性 – 将此设置为“无”会导致图像锚定在左上角.我怎么能改变这个?
注意:我使用的是.NET 2.0
只需在OnPaintBackground()方法中绘制它.将图像添加到资源(我称之为BkgImage)并使表单代码如下所示:
public Form1() { InitializeComponent(); backgroundImage = Properties.Resources.BkgImage; this.DoubleBuffered = true; this.SetStyle(ControlStyles.ResizeRedraw,true); } private Image backgroundImage; protected override void OnPaintBackground(PaintEventArgs e) { base.OnPaintBackground(e); var rc = new Rectangle(this.ClientSize.Width - backgroundImage.Width,this.ClientSize.Height - backgroundImage.Height,backgroundImage.Width,backgroundImage.Height); e.Graphics.DrawImage(backgroundImage,rc); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。