Binding Position Issue

cubemonkey

Member
Joined
Sep 19, 2005
Messages
6
Programming Experience
Beginner
I have a textbox that I enter an integer into and I want the Position in the database to display that record. It works fine when i use next and prev buttons to go though one at a time but not when I specify the exact record I want to view. Can I not set the .Position to a specific integer?

Dim bmSystem As BindingManagerBase
bmSystem = Me.BindingContext(Dswhatever1, "whatever")

txtWeaknessnum.DataBindings.Add(New System.Windows.Forms.Binding("Text", Dswhatever1, "whatever.Key"))

Dim intnum As Integer
intnum = (CInt(txtWeaknessnum.Text))
Try
If Not (intnum < 0 And intnum >= bmSystem.Count - 1) Then
bmSystem.Position = intnum ***fails here*****
End If
Catch ex As Exception
 
intnum = (CInt(txtWeaknessnum.Text))

change to:

VB.NET:
         Try
            intnum = Convert.ToInt32(txtWeaknessnum.Text)
        Catch ex As Exception
            intnum = 0
        End Try

Could be a problem converting to integer. You may want to check if the text is a number.
You could also add msgbox(intnum) after to see what it thinks the number is.
 
It's converting it fine. The number was stored as an integer. Is it just not possible to view a specific record based on a users input? Do anyone have any code of them doing this before? Im sure im not the first human to try this. Thanks!
 
this code works; I can't see a difference other than the line:

txtWeaknessnum.DataBindings.Add(New System.Windows.Forms.Binding("Text", Dswhatever1, "whatever.Key"))

try commenting it out:


VB.NET:
         Dim bmSystem As BindingManagerBase
        bmSystem = Me.BindingContext(DsShopNumber1, "Shop Number")

        Dim testnum As Integer
        Try
            testnum = Convert.ToInt32(TextBox1.Text)
        Catch ex As Exception
            testnum = 1
        End Try
        bmSystem.Position = testnum
 
Back
Top