按钮控件中的图像大小问题 [英] Problem with image size in button control

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

问题描述

你好朋友,
我正在做窗口应用程序的鞭子我把屁股.我正在处理按钮的鼠标进入"和鼠标离开"事件..
我使用了此编码

hello friends,,
I am making window application in whick i take butttons. i m working on Mouse Enter And Mouse Leave event of button..
i used this coding

private void button1_MouseEnter(object sender, EventArgs e)
{
    Button sender1 = (Button)sender;
    sender1.Height += 30;
    sender1.Width += 30;
    sender1.Top -= 15;
    sender1.Left -= 15;
}

private void button1_MouseLeave(object sender, EventArgs e)
{
    Button sender1 = (Button)sender;
    sender1.Height -= 30;
    sender1.Width -= 30;
    sender1.Top += 15;
    sender1.Left += 15;
}



它正在工作,但我想知道如何增加按钮上图像的大小
请帮助..



it is working but i want to know how to increase the size of image on button
pls help..

推荐答案

一种方法(也是我认为最简单的方法)是在鼠标进入时将图像更改为更大的图像,然后返回用鼠标移到原始位置.

我本来是建议ImageList的,但是我认为所有图像的大小都必须相同.另一方面,您也许可以放入不同大小的图像(0-256像素是有效范围),然后只需为ImageList设置ImageSize属性,然后在鼠标上更改图像索引输入/离开,但我不知道这样是否能按您想要的方式工作.
One way to do it (and the simplest I think) is to simply change the image to a larger one when the mouse enters, and back to the original with the mouse leaves.

I was originally going to suggest an ImageList, but I think all of the images have to be the same size. On the other hand, you might be able to put images of different sizes (0-256 pixels is the valid range) in, and then just set the ImageSize property for the ImageList *and* change the image index on mouse enter/leave, but I don''t know if that will work the way you want it to.


将背景图像添加到Button并将其属性设置为Stretch.
Add Background Image to Button and make its property as stretch.


我建​​议一种替代方法,但是如果它太遥远的话,请不要认真对待.我只是建议您考虑一下.

另一种选择是切换到WPF并仅使用矢量图形.在这种情况下,所有内容都是可缩放的.另外,您可以使一个控件的大小跟随其容器控件(带有边距/填充),因此可以自动调整大小.矢量图像的格式为XAML.您甚至可以允许用户在运行时提供自定义矢量图像.

另外,您可以使用名为Inkscape( http://en.wikipedia.org/wiki/Inkscape [ ^ ],^ ]).它与可缩放矢量图形格式(SVG, http://en.wikipedia.org/wiki/SVG [ ^ ],http://www.w3.org/Graphics/SVG/ [
I would suggest an alternative, but don''t take is seriously if it''s too remote; I just advise you to think about it.

The alternative is to switch to WPF and use only the vector graphics. In this case, everything is zoomable. Also, you can have the size of one control to follow its container control (with margin/padding) and so adjust the size automatically. The format for the vector image will be XAML. You can even allow your user to supply a custom vector image during run time.

Also, you can use a wonderful vector editor called Inkscape (http://en.wikipedia.org/wiki/Inkscape[^], http://www.inkscape.org/[^]). It works with Scalable Vector Graphics format (SVG, http://en.wikipedia.org/wiki/SVG[^], http://www.w3.org/Graphics/SVG/[^], a WWW standard) and can export XAML.

I will gladly give your more details and ask your questions, but only when and if you''re really interested.

—SA


这篇关于按钮控件中的图像大小问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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