gpt4 book ai didi

c# - 在 C# 中从 PictureBox 中删除图像

转载 作者:太空狗 更新时间:2023-10-29 20:18:27 24 4
gpt4 key购买 nike

当用户按下“del”键时如何从图片框中删除图像...我没有找到 PB 的任何按键或按键事件。

    private void topRight_pbx_MouseClick(object sender, MouseEventArgs e)
{
imgSelected=true;

//need to accept "delete"key from keyboard?

topRight_pbx.Image = null;
topRFile = "";

}

最佳答案

将您的 imgSelected 更改为类似的内容:

private PictureBox picSelected = null;

在您的图片框上单击将此变量设置为发件人:

picSelected = (PictureBox)sender;

然后在窗体的 keydown 或具有焦点的控件上运行图像删除代码(表格示例):

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
picSelected.Image = null;
}

关于c# - 在 C# 中从 PictureBox 中删除图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4553587/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com