How to limit the number of lines after ordering the Vb.net/C#datatable

Asked

Viewed 522 times

0

How do I limit the number of rows on a datagrid after Defaultview.Sort

Follows the code:

        da = New OleDbDataAdapter(MySQL, Conexao)
        dt = New DataTable("Pedidos")
        da.Fill(dt)
        dt.DefaultView.Sort = "Data Desc"
        Me.DataGridView1.DataSource = dt

I want to limit the number of lines after SORT, because the system has already ordered in the order I want.

1 answer

1

Try using Linq, probably as follows: dt.AsEnumerable().Take(10).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.