For some reason I cannot add rows when I use a BindingList<T> data source. I get a "Row insertion not supported by this data source." error. If I switch to a UltraDataSource I can add, but I would much prefer to use the bindinglist.
Is there something I can do to make it work with a binding list?
BindingList<T> should certainly support adding rows. Are you trying to add the row to the grid or to the BindingList directly?
Are you sure you are using BindingList<T> and not IBindingList or List<T>?
I couldn't use IBindingList since its abstract (an interface really). I used BindingList<String>.
When I clicked in the "add template row" (If that is what it is called. The row at the bottom where you can type to insert a new reow) and got the message.
I found another way around this. Since the default IBindingList implementation of BindingList can't create a new string, you could derive a class from BindingList<string> and override AddNewCore and return a new string yourself.
public class MyStrings : BindingList<string> { protected override object AddNewCore() { string s = string.Empty; return s; } }
There are probably other methods that you would need to override, also. So using a class with a string property might be easier.
Hm. I tried this out and I get the same results. This message doesn't come from the grid, it comes from the DotNet BindingManager. For some reason, BindingList doesn't support adding new items to the list.
I think this might be because you are using strings. I tried a simple test like so:
BindingList<string> strings = new BindingList<string>(); IBindingList bl = (IBindingList)strings;bl.AddNew();
With this code, I get an error that there is no Constrcutor on type 'System.String'. So it looks like the generic BindingList can't create a new string. So you will probably need to create a class with a string property and use that rather than a list of actual strings.