VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Navigating a Dataset Posted by sturner333 on 18 Nov 2008 at 9:18 AM
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
Report
Re: Navigating a Dataset Posted by seancampbell on 18 Nov 2008 at 9:56 AM
How are you binding your textbox to the dataset?

Have you tried doing the code in the TextBox1.TextChanged event?

    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


Hope this helps, if this doesn't help you solve your problem, try passing some code to us and a different description.
Report
Re: Navigating a Dataset Posted by sturner333 on 18 Nov 2008 at 10:07 AM
: How are you binding your textbox to the dataset?
:
: Have you tried doing the code in the TextBox1.TextChanged event?
:
:
: 
:     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
: 
:
:
: 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.

Report
Re: Navigating a Dataset Posted by seancampbell on 18 Nov 2008 at 11:06 AM
ok, what I was asking is how did you bind them? Can you show me code or what properties your set on the text box to achieve that? I have never bound an object like that, I prefer to query for and manipulate data before it gets displayed to a user... but I can probably help you if you give me more description.
Report
Re: Navigating a Dataset Posted by asponge on 20 Nov 2008 at 11:22 PM
: : How are you binding your textbox to the dataset?
: :
: : Have you tried doing the code in the TextBox1.TextChanged event?
: :
: :
: : 
: :     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
: : 
: :
: :
: : 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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.