Dar*_*ght 7 .net c# picturebox winforms
当用户按"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 = "";
}
Run Code Online (Sandbox Code Playgroud)
将您的 imgSelected 更改为:
private PictureBox picSelected = null;
Run Code Online (Sandbox Code Playgroud)
在图片框中单击将此变量设置为发件人:
picSelected = (PictureBox)sender;
Run Code Online (Sandbox Code Playgroud)
然后在表单或具有焦点的控件上按下按键,运行图像删除代码(表单示例):
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
picSelected.Image = null;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14050 次 |
| 最近记录: |