I have been beating my head against the wall on this one and I haven't been able to get it working - so I figured I'd ask here just in case it's something simple.
Basically, I have a DataGridView and I'm trying to add a row to it programatically.
Here is the code I'm using:
boundBookDataSet.LoadBoundBook.AddLoadBoundBookRow(
null, null, null, null, null, DateTime.Now, null, null, null,
false, false, -1, null, -1, -1);
I've also tried calling AcceptChanges on both the DataSet as well as the new DataRow after adding th开发者_StackOverflow中文版e row, and I've also tried calling Refresh on the DataGridView.
Anyway, no matter what I do, I end up with boundBookDataSet.LoadBoundBook.Count==70 and loadBoundBookBindingSource.Count==69. My DataGridView won't pick up the new row since it isn't reflected in the binding source (at least that's my guess).
Sadly, this was working - but I made a huge change and can't figure out what broke it. The code that is broken didn't change at all...
If anyone has any idea how to resolve this, I would seriously appreciate the help.
Aha! I figured it out. :)
As I was looking through the fields in my BindingSource once again, I realized I had the Filter field set. If I remove the filter, the loadBoundBookBindingSource.Count gets incremented correctly and the DataGridView picks up the new record.
Basically, it looks like I need to clear the filter, add the record, then set the filter again.
Assuming its winforms your talking about an answer to the problem is available on this thread: http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/f12158b3-4510-47cb-b152-409489c3a51a/
精彩评论