【问题标题】:Is it possible to change inputbox icon in vb.net?是否可以更改 vb.net 中的输入框图标?
【发布时间】:2013-03-08 07:14:07
【问题描述】:

我有一个从代码调用的输入框,虽然我的所有表单都有图标,但我在这个输入框上没有图标。由于它是消息框的标准选项,我觉得奇怪的是没有关于输入框的标准选项。

所以基本上,我该如何在这个输入框上获得一个图标?

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

注意:由于这是一个纯粹的审美问题,我并没有对此进行大量研究,因为此时还有更重要的工作要做。

【问题讨论】:

  • 制作自己的输入框。 vb自带的很烂。

标签: vb.net icons inputbox


【解决方案1】:

你可以试试我自己的输入框

输入表格

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 显示)

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

输入框完成后(整理)

DrZedInputbox.Dispose()

更新

添加照片

【讨论】:

  • 请注意:另外在取消按钮下方是另一个名为 btnResponse 的不可见按钮,我在其中存储了结果
【解决方案2】:

看起来您需要为此实现自己的对话框(本机不支持)。见:

以及在 google 上获得类似建议的其他结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-22
    • 1970-01-01
    • 2015-05-29
    • 2012-08-18
    • 1970-01-01
    • 2015-09-01
    • 2022-09-23
    • 2020-02-04
    相关资源
    最近更新 更多