gpt4 book ai didi

c# - 按钮图像边被裁剪

转载 作者:行者123 更新时间:2023-11-30 21:53:39 26 4
gpt4 key购买 nike

我正在尝试使图像完美适合按钮。但图像在其右侧和底面被裁剪,请参见附带的打印屏幕: enter image description here

我按如下方式编辑了按钮:

var l_oStopImage = Image.FromFile(@"C:\Users\AmitL\Downloads\Button-2-stop-icon72p.png");
var l_oStopPic = new Bitmap(l_oStopImage , new Size(btnStopOperation.Width, btnStopOperation.Height));
btnStopOperation.Image = l_oStopPic ;
btnStopOperation.ImageAlign = System.Drawing.ContentAlignment.MiddleCenter;

btnStopOperation.TabStop = false;
btnStopOperation.FlatStyle = FlatStyle.Flat;
btnStopOperation.FlatAppearance.BorderSize = 0;

我也尝试编辑 BackgroundImageLayout 但没有一个 ImageLayouts 解决了这个问题..

有什么建议吗?提前致谢

最佳答案

backgroundimage

1 https://msdn.microsoft.com/en-us/library/system.windows.forms.imagelayout(v=vs.110).aspx

我建议在设计时使用 stretch(这不是必须通过代码添加元素的 java):

            this.buttonOk.BackColor = System.Drawing.SystemColors.MenuHighlight;
this.buttonOk.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonOk.BackgroundImage")));
this.buttonOk.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonOk.Location = new System.Drawing.Point(475, 15);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(50, 50);
this.buttonOk.TabIndex = 11;
this.buttonOk.UseVisualStyleBackColor = false;
this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);

它会起作用,之前做过很多次

我从自己的工作 Form1.Designer.cs 中获得了这段代码,但正因为如此:请使用 Visual Studio 设计器,不要尝试在构造函数或其他内容中编写所有这些代码/逻辑。

关于c# - 按钮图像边被裁剪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33736675/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com