Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 绑定导航器导航混合_Vb.net_Datagridview_Sdf_Bindingnavigator - Fatal编程技术网

Vb.net 绑定导航器导航混合

Vb.net 绑定导航器导航混合,vb.net,datagridview,sdf,bindingnavigator,Vb.net,Datagridview,Sdf,Bindingnavigator,我有一个sdf数据库设置。单击“移动下一步”按钮时出现问题。因此,当我继续浏览记录时,它的顺序是:23、24、25、32、26、27、28、29、30、31、33、34。。。等等 但是它应该是25,26,27,28,29,30,31,32。。等等,对吗 这些数字是自动生成的记录ID,每增加一条新记录,这些数字就会递增。 在datagridview中查看记录时,顺序良好。有什么办法可以解决这个问题吗 更新 很抱歉迟了答复。我一直在尝试为记录导航创建一条替代路线,以便它按照ID号的顺序进行。我已经创

我有一个sdf数据库设置。单击“移动下一步”按钮时出现问题。因此,当我继续浏览记录时,它的顺序是:23、24、25、32、26、27、28、29、30、31、33、34。。。等等 但是它应该是25,26,27,28,29,30,31,32。。等等,对吗

这些数字是自动生成的记录ID,每增加一条新记录,这些数字就会递增。

在datagridview中查看记录时,顺序良好。有什么办法可以解决这个问题吗

更新 很抱歉迟了答复。我一直在尝试为记录导航创建一条替代路线,以便它按照ID号的顺序进行。我已经创建了一个变量Cur_navID,其中保存了当前记录ID。每次按下下一个或上一个按钮时,将按顺序显示下一条记录。但由于有数千条记录,这种方法往往有点模糊。总之,这里是主要代码

以下是代码:

新纪录

 Private Sub NewRecord()
    If Not isEditing = True Then
        Enable_edit()
        id += 1
        Me.BindingNavigatorAddNewItem.PerformClick()

        Cust_nameTextBox.Clear()
        ContactTextBox.Clear()
        RemTextBox.Clear()
        GradeTextBox.Clear()
        SchoolTextBox.Clear()
        V_numberTextBox.Clear()
        Student_nameTextBox.Clear()

        M7_idLabel1.Text = String.Format("{0:0000}", id)
        date_pick.Value = DateTime.Now

        StatusComboBox.SelectedIndex = 0
        StatusComboBox.Text = "To Be Done"
        setStatus(StatusComboBox.Text)

        Cust_nameTextBox.Focus()
    ElseIf isEditing = True Then
        Dim di As DialogResult = MsgBox("Do you want to save the current record?", MsgBoxStyle.YesNoCancel)
        If di = Windows.Forms.DialogResult.Yes Or di = Windows.Forms.DialogResult.OK Then
            SaveRecord()
            NewRecord()
        ElseIf di = Windows.Forms.DialogResult.No Then
            Canceledit()
        ElseIf di = Windows.Forms.DialogResult.Cancel Then
            Exit Sub
        End If
    End If
End Sub
保存记录

Private Sub SaveRecord()
    Try
        '// for customers with multiple lists. easier entry

        lastmember.cust_name = Cust_nameTextBox.Text
        lastmember.contact = ContactTextBox.Text
        lastmember.grade = GradeTextBox.Text
        lastmember.remks = RemTextBox.Text
        Cust_nameTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource
        Cust_nameTextBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        Dim MySource As New AutoCompleteStringCollection()
        MySource.Add(lastmember.cust_name)
        Cust_nameTextBox.AutoCompleteCustomSource = MySource

        Me.ListsBindingNavigatorSaveItem.PerformClick()
        Disable_edit()

        MsgBox("Record Saved!", MsgBoxStyle.Information)
        'AppWait(700)
        'ListsBindingSource.MoveLast()


        Cust_nameTextBox.Focus()
    Catch ex As Exception
        ' MsgBox("Please Fill in Customer Name, Contact and Grade Boxes", MsgBoxStyle.Information)
        MsgBox(ex.Message, MsgBoxStyle.Information)
    End Try
End Sub
绑定导航器保存项目代码

Private Sub ListsBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles ListsBindingNavigatorSaveItem.Click
    Me.Validate()
    Me.ListsBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.BooksListDataSet)
    My.Settings.ID = id
    My.Settings.Save()
End Sub
和表单加载事件

    ' ### Load data into the 'BooksListDataSet.Lists' table.
    Me.ListsTableAdapter.Fill(Me.BooksListDataSet.Lists)
    Me.BindingNavigatorMoveLastItem.PerformClick()


    ' ### Update counter if database changed
    Dim chek As Boolean = MAXID(BooksListDataSet.Tables("Lists")) = String.Format("{0:0000}", My.Settings.ID.ToString)
    If chek = False Then
        MsgBox("Database has been updated. Application will restart to compensate the changes.", MsgBoxStyle.Information)
        ' My.Settings.ID = Me.BooksListDataSet.Tables("Lists").Rows(BooksListDataSet.Tables("Lists").Rows.Count - 1).Item(0).ToString
        My.Settings.ID = MAXID(BooksListDataSet.Tables("Lists"))
        My.Settings.Save()
        Application.Restart()
    Else
    End If


    ' ### Take backup
    If My.Settings.backup_date = Nothing Then
        Dim di As DialogResult = MsgBox("Do you want to create a backup database?", MsgBoxStyle.YesNoCancel)
        If di = Windows.Forms.DialogResult.Yes Or di = Windows.Forms.DialogResult.OK Then
            '//backup database
            If Not My.Computer.FileSystem.FileExists(Path.Combine(Application.StartupPath.ToString, My.Settings.ID.ToString & "BooksList.sdf.BAK")) Then
                My.Computer.FileSystem.CopyFile(Path.Combine(Application.StartupPath.ToString, "BooksList.sdf"), Path.Combine(Application.StartupPath.ToString, My.Settings.ID.ToString & "BooksList.sdf.BAK"))
                My.Settings.backup_date = Date.Today
                My.Settings.Save()
            End If

        Else
            'do nothing
        End If
    ElseIf Not My.Settings.backup_date = Date.Today Or My.Computer.FileSystem.FileExists(Path.Combine(Application.StartupPath.ToString, My.Settings.ID.ToString & "BooksList.sdf.BAK")) = False Then
        Dim di2 As DialogResult = MsgBox("Do you want to create todays backup database now?", MsgBoxStyle.YesNoCancel)
        If di2 = Windows.Forms.DialogResult.Yes Or di2 = Windows.Forms.DialogResult.OK Then
            '//backup database
            If Not My.Computer.FileSystem.FileExists(Path.Combine(Application.StartupPath.ToString, My.Settings.ID.ToString & "BooksList.sdf.BAK")) Then
                My.Computer.FileSystem.CopyFile(Path.Combine(Application.StartupPath.ToString, "BooksList.sdf"), Path.Combine(Application.StartupPath.ToString, My.Settings.ID.ToString & "BooksList.sdf.BAK"))
                My.Settings.backup_date = Date.Today
                My.Settings.Save()
            End If

        Else
            'do nothing
        End If
    End If

    ' ### Load Autopcomplete list
    Dim autocompleteList As New System.Windows.Forms.AutoCompleteStringCollection
    Using reader As New System.IO.StreamReader("Schools.ACL")
        While Not reader.EndOfStream
            autocompleteList.Add(reader.ReadLine())
        End While
    End Using
    SchoolTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource
    SchoolTextBox.AutoCompleteMode = AutoCompleteMode.Suggest
    SchoolTextBox.AutoCompleteCustomSource = autocompleteList

    ' ### Focus next textbox on enter function part
    textBoxes.Add(Cust_nameTextBox)
    textBoxes.Add(ContactTextBox)
    textBoxes.Add(RemTextBox)
    textBoxes.Add(GradeTextBox)
    textBoxes.Add(SchoolTextBox)
    textBoxes.Add(V_numberTextBox)
    textBoxes.Add(Student_nameTextBox)

    Disable_edit()
    Cur_navID = MAXID(Me.BooksListDataSet.Tables("Lists"))
    Me.ListsBindingSource.Position = Cur_navID

它们在你的sdf中是什么样子的?另外,请添加代码,以便我们能够更好地帮助你…在sdf文件中按正确的顺序排列。25, 26, 27, 28, 29, 30, 31, 32.... 我应该发布代码的哪一部分?因为我不知道这发生在哪里。因此,如果您能建议代码的哪一部分,那么绑定ect将是一个很好的开始