我想在按钮内添加图标。这里是我的代码如何在按钮内显示图标windowsForms
private void Printbutton_Click(object sender, EventArgs e)
{
// Assign an image to the button.
Printbutton.Image = Image.FromFile("D:\\Downloads\\print.png");
// Align the image and text on the button.
Printbutton.ImageAlign = ContentAlignment.MiddleRight;
Printbutton.TextAlign = ContentAlignment.MiddleLeft;
// Give the button a flat appearance.
Printbutton.FlatStyle = FlatStyle.Flat;
if (SetupThePrinting())
printDocument1.Print();
}
这里的问题是,该图标没有出现在第一,当我点击该按钮出现。
这里有什么问题?
你加入printbutton_click事件中的图标,而不是将其定义表格initializecomponents –
@SebastianSchulz我如何准确地做? –