Changes in BindingSource not reflected in DataGridView

Changes in BindingSource not reflected in DataGridView

Post by billygote » Wed, 14 Jun 2006 03:48:18


Hello, please bear with me on a question that seems to be asked all
over (but for me, not adequately answered!). I have been trying to
figure out what I'm missing for days now and haven't found a good
explanation. The IDE is VS .NET 2k5.

Suppose I have a DataGridView alone on a form. My goal is to
initialize it with a set number of rows and columns, such that a user
can fill the cells in but not add or delete rows (properties which are
set to false on the DataGridView). I would also like these changes
reflected in a data source that I've created. To do this my steps are
the following:

Create a BindingSource and associate it with my data source, and then
manually add new objects to the BindingSource like so:

this.<BindingSourceName>.Add(new <data source name>());

This will propogate the new additions to the data source associated
with it as expected. Since the BindingSource is already associated
with the DataGridView control, I would expect this to be adequate.

The problem is, when the form is initialized, the DataGridView's
RowCount is not the same as the capacity of my data source. This means
all I see are a bunch of columns headers with no data entry cells. If
I allow the user to Add a new row, the DataGridView initializes with a
single row visible which contains the data that I manually submitted to
it via the Add() function earlier.

So my question is, why is it that my DataGridView does not see that it
isn't displaying the right number of rows? I have tried to call
ResetBindings(true); of the BindingSource as well as set the
BindingSource.DataSource = null; and back to the original data source
and it does not reflect in the DataGridView that a change was made. I
am stuck.
 
 
 

Changes in BindingSource not reflected in DataGridView

Post by Brando » Thu, 15 Jun 2006 03:53:38

Geez...disregard. There was a problem in my row calculation.