本文介绍了没有从我的UserControl的Value获得的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个用户控件,只接受数字数字。
我在表单上使用此控件计算总共2个数字
我在两个控件中输入了一些值。数字显示(前10,20)
但我没有得到总数。为什么&怎么做。
i在我的usercontrol中写了以下代码
i created a user control to accept only Numerical Digits.
I used this control on my form to calculate total of 2 numbers
i entered some values in both controls. digits are showing (ex 10, 20)
but iam not getting the total. why & what to do.
i had written the following code in my usercontrol
Public Class Number2
Public Event TxtN_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Private Sub txtN_KeyPress1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtN.KeyPress
If e.KeyChar <> "." And (e.KeyChar < "0" Or e.KeyChar > "9") Then
e.Handled = True
End If
End Sub
Private Sub txtN_LostFocus1(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtN.LostFocus
txtN.Text = FormatNumber(Val(txtN.Text), 2, , , False)
End Sub
Private Sub txtN_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtN.TextChanged
RaiseEvent TxtN_TextChanged(sender, e)
End Sub
Property txtNtext() As String
Get
txtNtext = txtN.Text
End Get
Set(ByVal value As String)
txtN.Text = value
End Set
End Property
End Class
' and in form i am using it as
Private Sub txtN1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtN1.LostFocus
txtN3.Text = FormatNumber(Val(txtN1.Text) + Val(txtN2.Text), 3, , , TriState.False)
End Sub
但是它的lostfocus中没有任何计算
but nothing is calculating in its lostfocus
推荐答案
这篇关于没有从我的UserControl的Value获得的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!