L
L
leremin2018-05-30 15:30:12
C++ / C#
leremin, 2018-05-30 15:30:12

How to remove the added row when adding an empty DataSource to the BindingSource?

If BindingSource.DataSource is assigned an empty list, then an empty string is added. How to make it not added? AllowNew is false;
So far I've done this:

var items = GetItems();
bindingSource.DataSource = items.Count > 0 ? items : (object) typeof(Item);

But it seems to me that this is a crutch and there should be another way.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question