Frage

I have an inputbox which is called from code, yet while I have icons for all my forms, I don't get an icon on this inputbox. Since it's a standard option for messageboxes, I think it's weird there isn't a standard option for it concerning inputboxes.

So basically, how do I go at it to get an icon onto this inputbox?

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

Note: as this is a purely aesthetic problem, I haven't really researched this a lot because there's more important work to be done at this point.

War es hilfreich?

Lösung

You can try my own inputbox

THE INPUT FORM

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

THE WRAPPER

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

THE IMPLEMENTATION

To display the inputbox

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

To collect the results (shown using a msgbox)

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

When finished with the inputbox (tidy up)

DrZedInputbox.Dispose()

UPDATE

Added photo

DrZed.Inputbox sample

Andere Tipps

Looks like you would need to implement your own dialog for that (not supported natively). See:

And other results on google with a similar advise.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top