我正在使用VB2012,如何增加输入框的字体大小?
Dim inputBoxMessage As String = "You are picking part : "
For count = 0 To dgv_partDetails.Rows.Count - 1
If dgv_partDetails.Rows.Count = 0 Then
答案 0 :(得分:0)
以下假设您要在DataGridView外部请求用户输入。如果不是这种情况就停在这里。
创建一个新表单,添加两个按钮,将一个DialogResult设置为OK,另一个设置为Cancel,在两个按钮的属性窗口中执行此操作。添加标签(将自动调整大小设置为false)和TextBox,将字体设置为您希望的方式。设置FormBorderStyle = FixedToolWindow,将StartPosition设置为CenterParent。
按如下所示调用对话框
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim f As New frmUserInput
Dim Value As Integer = 0
Try
f.lblQuestion.Text = "your question"
f.Text = "Question"
' optional
f.txtInput.Text = "100"
If f.ShowDialog = Windows.Forms.DialogResult.OK Then
If Not String.IsNullOrWhiteSpace(f.txtInput.Text) Then
' Work with data, lets say we want a numeric
If Integer.TryParse(f.txtInput.Text, Value) Then
' use value varible
Else
MessageBox.Show("Not a valid integr [" & f.txtInput.Text & "]")
End If
End If
End If
Finally
f.Dispose()
End Try
End Sub
End Class
或者我们可以在创建表单
时设置属性Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim f As New frmUserInput
Dim Value As Integer = 0
Try
Dim specialFont As Font = New Font(
"Microsoft Sans Serif", 12.0!,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
f.lblQuestion.Text = "your question"
f.lblQuestion.Font = specialFont
f.lblQuestion.ForeColor = System.Drawing.Color.Red
f.Text = "Question"
' optional
f.txtInput.Text = "100"
If f.ShowDialog = Windows.Forms.DialogResult.OK Then
If Not String.IsNullOrWhiteSpace(f.txtInput.Text) Then
' Work with data, lets say we want a numeric
If Integer.TryParse(f.txtInput.Text, Value) Then
' use value varible
Else
MessageBox.Show("Not a valid integr [" & f.txtInput.Text & "]")
End If
End If
End If
Finally
f.Dispose()
End Try
End Sub
End Class
我个人会将此代码包装到类或代码模块中而不是表单中,因此可以在代码中的多个位置使用它。