这是我的代码
Private Sub open_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles open_btn.Click
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
PictureBox1.Load(OpenFileDialog1.FileName)
End If
如果打开图像,是否可以同时在资源中添加该图像? 请帮帮我。
答案 0 :(得分:0)
是的,可以这样做,但如果这是期望的话,它们将不会成为您申请的一部分。相反,您的应用程序将依赖于外部资源文件。
Dim result As DialogResult = openFileDialog1.ShowDialog()
If result = DialogResult.OK Then
Dim bitmap As New Bitmap(openFileDialog1.FileName)
Dim writer = New ResourceWriter("my.resources")
writer.AddResource("myImage", bitmap)
writer.Close()
End If
一些参考: How to use Resources.resx dynamically i,e add new items dynamically https://msdn.microsoft.com/en-us/library/stf461k5(v=vs.110).aspx