简体   繁体   中英

C#: Flip image horizontally

What I'm trying to do is, to flip image horizontally on radio button click.

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
    arrow.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
    arrow.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
}

The code above doesn't flip image: image stays as it is. What am I missing?

You need to cause it to redraw, you can force this manually by doing

 private void radioButton1_CheckedChanged(object sender, EventArgs e)
 {
     arrow.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
     arrow.Invalidate() ;
 }

You should also only have this on one of the radio buttons, not both, otherwise they'll negate each other, so replace your current stuff with the above. Just verified it works under vs2005, don't have vs2010 handy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM