kviki
kviki

Reputation: 21

How to add not all data to datagridview?

I have data with 40+ items.

I use datagridview to show them.

BindingSource binding = new BindingSource();
binding.DataSource = MyList;

dataGridView.DataSource = binding;

But I need to show only 10 items. How can I do it?

Upvotes: 1

Views: 37

Answers (2)

asem mokllati
asem mokllati

Reputation: 245

Try this code

BindingSource binding = new BindingSource();
        binding.DataSource = MyList.Take(10);

        dataGridView.DataSource = binding;

Upvotes: 0

dmay
dmay

Reputation: 1325

binding.DataSource = MyList.Take(10).ToList();

Upvotes: 2

Related Questions