Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Navigating a Dataset

sturner333sturner333 Posts: 3Member
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

  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    How are you binding your textbox to the dataset?

    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.
  • sturner333sturner333 Posts: 3Member
    : How are you binding your textbox to the dataset?
    :
    : 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.

  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    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.
  • aspongeasponge Posts: 42Member
    : : How are you binding your textbox to the dataset?
    : :
    : : 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.
Sign In or Register to comment.