今天在用Dev的simblebutton 时遇到了一个非常无语的问题,就是设置背景图片无效。直接在属性里设置背景backgroudImage,图片上不显示。由于以前没有用过Dev,用WinForm的按钮试了一下,能设置上,但是simblebutton不行。
参考了这篇文章
https://bbs.youkuaiyun.com/topics/390765884
发现设置一个背景图片,需要设置好几个地方,其实设置完backgroudimage后前面几个项自动就加上了,但是按钮上不显示图片,一定要手动设置红色的两行,必须是两行。
LookAndFeel.UseDefaultLookAndFeel 默认是true,图片是不显示的。
按照下面的设置好后,终于背景图加上了。
有一个问题始终没弄明白,就是dev的界面里加了几个winform的按钮,又修改了一下界面的字体后,那几个winform的按钮总是不在我期望的位置上。不太明白。最终还是统一都用dev的控件了。
this.simpleButton1.Appearance.BackColor = System.Drawing.Color.Transparent;
this.simpleButton1.Appearance.Options.UseBackColor = true;
this.simpleButton1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("simpleButton1.BackgroundImage")));
this.simpleButton1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.simpleButton1.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.UltraFlat;
this.simpleButton1.Location = new System.Drawing.Point(45, 6);
this.simpleButton1.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.UltraFlat;
this.simpleButton1.LookAndFeel.UseDefaultLookAndFeel = false;
this.simpleButton1.Name = "simpleButton1";
this.simpleButton1.Size = new System.Drawing.Size(218, 120);
this.simpleButton1.TabIndex = 0;