The issue I am having is, I cannot get the "e.Graphics" lines of code to work if I try to use them in a button1_Click method. So, I have constructed "Paint" method. Now I can't seem to call the Paint method from the button Click event. Is there a way to do this? I have not been able to find a way to make this work. Or, is there a way to do the e.Graphics functions in the "button1_Click" method?
Thank you
public void button1_Click(object sender, EventArgs e)
{
CrochetPtrnDesign_Paint(this, ?);
}
private void CrochetPtrnDesign_Paint(object sender, PaintEventArgs e)
{
Rectangle rect = new Rectangle(5, 5,
ClientSize.Width - 10, ClientSize.Height - 10);
e.Graphics.DrawRectangle(Pens.Red, rect);
using (Font font = new Font("Times New Roman", 16, GraphicsUnit.Pixel))
{
using (StringFormat sf = new StringFormat())
{
// Middle.
sf.LineAlignment = StringAlignment.Center; // Middle.
// Middle/Center.
sf.Alignment = StringAlignment.Center; // Center.
e.Graphics.DrawString("Middle/Center", font, Brushes.Black, rect, sf);
}
}