3

コードから呼び出される入力ボックスがありますが、すべてのフォームにアイコンがありますが、この入力ボックスにアイコンが表示されません。メッセージボックスの標準オプションなので、入力ボックスに関して標準オプションがないのはおかしいと思います。

基本的に、この入力ボックスにアイコンを取得するにはどうすればよいですか?

inventory = InputBox("Inventory:" & vbCrLf & "Make sure this is correct, as an error can cause failure to login.", "Edit Inventory", oldinv)

注: これは純粋に審美的な問題であるため、この時点でさらに重要な作業を行う必要があるため、あまり調査していません。

4

2 に答える 2

2

自分の入力ボックスを試すことができます

入力フォーム

Public Class frmInputbox

  Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    btnResponse.Text = MsgBoxResult.Ok
    Me.Hide()
  End Sub

  Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
    btnResponse.Text = MsgBoxResult.Cancel
    Me.Hide()
  End Sub

End Class

ラッパー

Public Class DrZedInputbox

  Private Shared _UserResponseDlg As New frmInputbox()

  Public Shared Function Inputbox(Prompt As String, Title As String, ByRef TextData As String, Left As Integer, Top As Integer, Icon As System.Drawing.Icon) As MsgBoxResult
    Inputbox = MsgBoxResult.Cancel
    _UserResponseDlg.Text = Title
    _UserResponseDlg.Label1.Text = Prompt
    _UserResponseDlg.TextBox1.Text = textData
    _UserResponseDlg.Left = Left
    _UserResponseDlg.Top = Top
    _UserResponseDlg.Icon = Icon
    _UserResponseDlg.ShowDialog()
    Inputbox = _UserResponseDlg.btnResponse.Text
  End Function

  Public Shared ReadOnly Property TextData As String
    Get
      Return _UserResponseDlg.TextBox1.Text
    End Get
  End Property

  Public Shared ReadOnly Property Response As MsgBoxResult
    Get
      Return CType(_UserResponseDlg.btnResponse.Text, MsgBoxResult)
    End Get
  End Property

  Public Sub Dispose()
    _UserResponseDlg = Nothing
  End Sub

  Protected Overrides Sub Finalize()
    _UserResponseDlg = Nothing
    MyBase.Finalize()
  End Sub

End Class

実装

入力ボックスを表示するには

DrZedInputbox.Inputbox("prompt", "title", "default", 100, 100, Me.Icon)

結果を収集するには (メッセージボックスを使用して表示)

MsgBox("Text data entered: " & DrZedInputbox.TextData)
MsgBox("User response: " & DrZedInputbox.Response)

入力ボックスの処理が終わったら (片付け)

DrZedInputbox.Dispose()

アップデート

写真追加

DrZed.Inputbox サンプル

于 2013-03-19T17:17:31.523 に答える
1

そのためには独自のダイアログを実装する必要があるようです (ネイティブではサポートされていません)。見る:

同様のアドバイスを含むGoogleの他の結果。

于 2013-03-19T14:54:45.603 に答える