| |

VerySource

 Forgot password?
 Register
Search
View: 657|Reply: 8

VB.NET positioning problems in DataGride

[Copy link]

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-20 21:00:02
| Show all posts |Read mode
I am newbie and recently made a small MIS
The original modification function must be selected from the DataGrid3 and then modified.
Because the front desk provides users to change the password
So DataGrid3 is hidden when it is displayed, so it cannot be selected.
So you must locate the user's line in advance. The following is my method. However, read and read are the first line of data. Please help the master.

 Private Sub newa ()
       'definition
        Dim olecn As New OleDbConnection ("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = d:\data\Clients.mdb")
        Dim olecm As New OleDbCommand ("select * from StudentUser", olecn)
        Dim olead As New OleDbDataAdapter
        Dim olerd As OleDbDataReader
        Dim pd As Boolean = False 'Define boolean for later error handling
        Dim i As Integer
        olecm = New OleDbCommand ("select * from StudentUser", olecn)
        'Establish a connection to the database
        olecn.Open ()
        olerd = olecm.ExecuteReader
        'Loop judges whether the data in the database is the same



        Do While olerd.Read ()
            For i = 0 To olerd.FieldCount-1
                If Trim (login.zhtl.Text) = (olerd.Item ("Usename")) Then
                    Me.DataGrid3.CurrentRowIndex = i
                   

                    Exit Sub
                End If
            Next
        Loop
      


    End Sub
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-31 21:36:01
| Show all posts
The rows in datagrid start from 1. Your i is calculated from 0. You put me.datagrid3.currentrowindex = i
Replace with me.datagrid3.currentrowindex = i + 1
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-2-9 08:30:02
| Show all posts
It doesn't seem to work
Reply

Use magic Report

1

Threads

5

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-10 16:30:01
| Show all posts
me.datagrid3.CurrentCell.RowNumber = i
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-2-12 18:30:01
| Show all posts
me.datagrid3.CurrentCell.RowNumber = i
Changed
Hint Error 13 The expression is a value and therefore cannot be used as an assignment target.
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-2-19 16:30:01
| Show all posts
Waiting for the Supreme
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-3-3 16:45:01
| Show all posts
continue waiting
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-5 21:15:01
| Show all posts
How many columns does FieldCount have? I don't understand what you use for this loop.
Do While olerd.Read ()
    If Trim (login.zhtl.Text) = (olerd.Item ("Usename")) Then
        Me.DataGrid3.CurrentRowIndex = i
           Exit Sub
      End If
      i + = 1
Loop
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-3-10 13:15:01
| Show all posts
The problem is solved
Thank this senior
I thought it was the calling line ..... Because it is a beginner, I don't know many objects ...
If only I knew more about datagraid.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list