Ich möchte Symbol in einer Schaltfläche hinzufügen. Hier ist mein Codewie Symbol in einer Schaltfläche zu zeigen 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();
}
Das Problem hierbei ist, dass das Symbol nicht auf dem ersten angezeigt wird, es erscheint, wenn ich auf die Schaltfläche klicken.
Was ist hier falsch?
Sie das Symbol in printbutton_click Ereignisse statt definiert es in dem Formular –
@SebastianSchulz InitializeComponents hinzugefügt Wie ich mach es genau? –