我为表单设置了backGround图片,并将从右到左属性设置为否,并将从右到左布局设置为 false 并尝试使用按钮更改这些内容,但是当我单击按钮时,我不会渲染并且backGround为白色。(Windows形式为C#)。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication9
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.RightToLeft = RightToLeft.Yes;
this.RightToLeftLayout = true;
}
}
}
答案 0 :(得分:2)
答案 1 :(得分:0)
似乎我们无法在表格设置从右到左布局时设置图像,但一种方法是欺骗用户查看图片。使用面板底座来填充和设置面板用户的图像背景只会看到图片。检查代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.RightToLeft = RightToLeft.Yes;
this.RightToLeftLayout = true;
Panel pnl = new Panel();
pnl.Dock = DockStyle.Fill;
pnl.BackgroundImage = System.Drawing.Image.FromFile("D:\\Picture\\Graphic\\2\\(1).png");//address of your image
pnl.BackgroundImageLayout = ImageLayout.Stretch;
this.Controls.Add(pnl);
}
}
}