tabcontrol中的紧凑框架图像 [英] Compact Framework Images inside tabcontrol

查看:87
本文介绍了tabcontrol中的紧凑框架图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!



我在Compact Framework应用程序中使用tabcontrol,我想在不同的标签页中添加图像。



由于Compact Framework不允许通过设计属性包含图像,我想知道如何添加不同的图像。



使用覆盖OnPaint我可以更改背景图像,但我无法更改tabpages背景图像。



提前感谢您的帮助。



Hello!

I'm using a tabcontrol in a Compact Framework application and I want to add images in the different tabpages.

As Compact Framework does not allow to include the images via design properties, I want to know how I can add different images.

Using "Override OnPaint" I can change the background image, but I can´t change the tabpages background images.

Thanks in advance for the help.

private Bitmap backgroundImage = null;	

void TabPage1Paint(object sender, PaintEventArgs e)
{
    backgroundImage = new Bitmap(folderpath+ "\\backgroundImage.png");
    e.Graphics.DrawImage(backgroundImage, this.ClientRectangle, new Rectangle(0, 0, this.Width, this.Height), GraphicsUnit.Pixel);   
}   

推荐答案

小心背景图片;可以做的内容可读性差。更喜欢均匀的颜色,或者只是略微纹理化的近乎均匀的背景。



通常,它是 https://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.backgroundimage %28v = vs.110%29.aspx [ ^ ]。



它没有说Compact Framework支持它,因此您可以覆盖 OnPaint 或处理 Paint 事件。在这两种情况下,您都使用在事件参数中传递的 System.Drawing.Graphics 的实例,并使用它来绘制图像:https://msdn.microsoft.com/en-us/library/system.drawing.graphics .drawimage%28v = vs.110%29.aspx [ ^ ]。







使用您自己类型的标签页(如果您使用 OnPaint 则需要这样,因为您只能覆盖您的方法派生类),使用这种添加页面的方法:

https://msdn.microsoft.com/en-us/library/68d9sedf%28v=vs.110%29.aspx [ ^ ]。



如果您处理 Paint ,您可以在每次添加时添加处理程序新页面。



-SA
Be careful with background images; the can do content poorly readable. Better prefer uniform color, or only slightly textured near-uniform backgrounds.

Normally, it's https://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.backgroundimage%28v=vs.110%29.aspx[^].

It does not say it's supported in Compact Framework, so you can override OnPaint or handle Paint event. In both cases, you use the instance of System.Drawing.Graphics passed in event arguments and use it to draw an image: https://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawimage%28v=vs.110%29.aspx[^].



To use the tab page of your own type (which would be required if you use OnPaint, because you can only override method in your derived class), use this method of adding a page:
https://msdn.microsoft.com/en-us/library/68d9sedf%28v=vs.110%29.aspx[^].

If you handle Paint, you can add the handler each time you add a new page.

—SA


这篇关于tabcontrol中的紧凑框架图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆