カスタムフォームダイアログボックスを開くローンプログラムを作成しています。画像を選択し、[開く]をクリックして、ダイアログボックスから[OK]を押した後に使用する別のフォームに渡す必要があります。これは、カスタム ダイアログ フォームから [ロゴ ファイル] ボタンをクリックしたときのコードです。
フォームはダイアログ フォームと呼ばれ、画像を NewLoanCaculatorForm に送信してフォームの画像領域に入力する必要があります。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogoFile.Click
Dim mystream As Stream = Nothing
'Open the File to pickup icon for Loan Calculator
Dim OpenFileDialog1 As New OpenFileDialog
'Set up and display the open File Dialog
With OpenFileDialog1
'Begin in the current Directory
.InitialDirectory = "C:\"
.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
End With
If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Try
mystream = OpenFileDialog1.OpenFile()
If (mystream IsNot Nothing) Then
' I believe the coded goes here but I'm stuck
End If
Catch Ex As Exception
MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
Finally
' Check this again, since we need to make sure we didn't throw an exception on open.
If (mystream IsNot Nothing) Then
mystream.Close()
End If
End Try
End If
End Sub