2013-03-19 39 views
3

我有一個從代碼調用的輸入框,但雖然我有所有我的窗體的圖標,但我沒有在此輸入框上顯示圖標。由於它是messageboxes的標準選項,我認爲這很奇怪,因爲它沒有關於inputbox的標準選項。是否可以在vb.net中更改輸入框圖標?

所以基本上,我該如何去這個輸入框上的圖標?

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

注:因爲這是一個純粹的審美問題,我還沒有真正研究這個有很多,因爲有在這一點上做更重要的工作。

+4

M ake你自己的InputBox。 vb自帶的那個很爛。 – Jaxedin 2013-03-19 15:20:19

回答

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) 

當與輸入框結束(使用一個MsgBox示出)(整理)

DrZedInputbox.Dispose() 

UPDATE

添加照片

DrZed.Inputbox sample

+0

請注意:另外在取消按鈕下是另一個名爲btnResponse的不可見按鈕,其中我存儲了結果 – Zeddy 2013-03-19 17:20:21

1

看起來你需要實現自己的對話框(本地不支持)。見:在谷歌

和其他結果有類似的建議。

相關問題