What is the best place (event/procedure) to use the newest record when navigating from record to record on a form.
For example, I want to do a calculation on 2 text boxes that are bound to a dataset. This calculation will be done each time a new record is navigated to.
This seams basic but I am new to .net and can't see, to find the best way.
Thanks
Comments
Have you tried doing the code in the TextBox1.TextChanged event?
[code]
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox3.Text = CDbl(Textbox1.Text) * CDbl(Textbox2.Text)
'CDbl stands for Covert Double, which converts an object (such as string or integer) to a Double value.
'A Double variable holds Decimal (floating point) data (numbers such as 2.12)
'Where as an integer would round to the nearest whole number (CInt)
'CInt(2.12) = 2
'CInt(2.5) = 3
'This event will be triggered each character you type or delete from the text box, or any other time the value of TextBox1 changes...
End Sub
[/code]
Hope this helps, if this doesn't help you solve your problem, try passing some code to us and a different description.
:
: Have you tried doing the code in the TextBox1.TextChanged event?
:
: [code]:
: Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
: TextBox3.Text = CDbl(Textbox1.Text) * CDbl(Textbox2.Text)
: 'CDbl stands for Covert Double, which converts an object (such as string or integer) to a Double value.
: 'A Double variable holds Decimal (floating point) data (numbers such as 2.12)
: 'Where as an integer would round to the nearest whole number (CInt)
: 'CInt(2.12) = 2
: 'CInt(2.5) = 3
:
: 'This event will be triggered each character you type or delete from the text box, or any other time the value of TextBox1 changes...
: End Sub
: [/code]:
:
: Hope this helps, if this doesn't help you solve your problem, try
: passing some code to us and a different description.
The textboxes that I will use to calculate are bound to the dataset so they change as I navigate from record to record. I tried the text_change event anyway and it didn't work.
: :
: : Have you tried doing the code in the TextBox1.TextChanged event?
: :
: : [code]: :
: : Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
: : TextBox3.Text = CDbl(Textbox1.Text) * CDbl(Textbox2.Text)
: : 'CDbl stands for Covert Double, which converts an object (such as string or integer) to a Double value.
: : 'A Double variable holds Decimal (floating point) data (numbers such as 2.12)
: : 'Where as an integer would round to the nearest whole number (CInt)
: : 'CInt(2.12) = 2
: : 'CInt(2.5) = 3
: :
: : 'This event will be triggered each character you type or delete from the text box, or any other time the value of TextBox1 changes...
: : End Sub
: : [/code]: :
: :
: : Hope this helps, if this doesn't help you solve your problem, try
: : passing some code to us and a different description.
:
: The textboxes that I will use to calculate are bound to the dataset
: so they change as I navigate from record to record. I tried the
: text_change event anyway and it didn't work.
:
:
Assuming that you're using a BindingSource and BindingNavigator on your Form, you can handle the CurrentChanged event of the BindingSource object to determine when the user navigates to a new record.
Within the CurrentChanged event handler use the Current property of the BindingSource object to get the record currently loaded onto the form.