c# - 图片框上的清晰图像

标签 c# .net winforms picturebox

如何清除图片框上的绘制图像? 以下内容对我没有帮助:

pictbox.Image = null;
pictbox.Invalidate();

请帮忙。

编辑

private void pictbox_Paint(object sender, PaintEventArgs e) 
{ 
     Graphics g = e.Graphics; 
     vl.Draw(g, ref tran.realListForInsert); 
} 

public void Draw(Graphics g, ref List<double> arr) 
{ 
    g.DrawRectangle(new Pen(Brushes.Red, 3), nodeArr[Convert.ToInt32(templstName)].pict.Location.X, nodeArr[Convert.ToInt32(templstName)].pict.Location.Y, 25, 25); 
    g.DrawRectangle(new Pen(Brushes.Green, 3), nodeArr[Convert.ToInt32(templstArgName)].pict.Location.X, nodeArr[Convert.ToInt32(templstArgName)].pict.Location.Y, 25, 25); 
    nodeArr[Convert.ToInt32(templstName)].text.Text = arr[Convert.ToInt32(templstArgName)].ToString(); 
    arr[Convert.ToInt32(templstName)] = arr[Convert.ToInt32(templstArgName)]; 
} 

最佳答案

设置Image property到 null 会工作得很好。它将清除图片框中当前显示的任何图像。确保您编写的代码完全像这样:

picBox.Image = null;

关于c# - 图片框上的清晰图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5856196/

相关文章:

c# - 调用另一个线程函数然后返回值

.net - 为什么 Nullable<T> 不实现 IComparable?

c# - 在 VB.Net 或 C# 中保存设置

C# Winform 在 SerialPort.Close 上卡住

c# - TabControl 和边框视觉故障

c# - 推荐的 c# winform 控件包

c# - 在 .NET 4.5 beta 中获取 System.Net.Mail.MailMessage 作为 MemoryStream

c# - 如何从一个对象启动两个并行线程?

c# - 如何避免在 C# 命名空间中定义冗余枚举?

vb.net - 在设计器中打开 VB.NET Windows 窗体时出现错误 "Value cannot be null. Parameter name: objectType"