Marc Gravell wrote:
And you are sure that myDataTable isn't null?
Are there any threads involved? (since the DataGrid is a winform
control, it could create issues if you are changing the property on the
wrong thread).
Inside the DataSource setter, it checks:
if ((this.dataSource == null) || !this.dataSource.Equals(value))
{
if (((value == null) || (value == Convert.DBNull)) &&
((this.DataMember != null) && (this.DataMember.Length != 0)))
{blah}
if second "if" returns true, ir runs simple code (and doesn't fire
event); if it returns false (real data source) it calls:
this.EnforceValidDataMember(value); // only if value not null
this.ResetParentRows();
this.Set_ListManager(value, this.DataMember, false);
It is this last that fires the event, but it is very complex. Could any
of this explain your issue? Is the data really valid? Is it non-null?
On the right thread? etc.
Marc
Marc,
First, where are you getting all of these details about how the
datasource operates?
The data is there in myDataTable. I see a table name when mousing over
it and when looking at the data debug view (clicking the magnifying
class), I see all of the columns and rows of data. This is a single
threaded app.
this.datasource is null because of the first null assignment I do.
value is valid with data and the two are different. All of the
conditions are correct to trigger the event. DataMember is not being
used.
It's to much explaining without walking through the code but here's a
little info on the overall picture:
The form in question (FormA) is in an MDI app. Double clicking a row
in the datagrid opens FormB in the MDI. The user can make an update on
FormB and click an update button. This fires an event that FormA is
listening for and reassigns the datasource of the grid on FormA.
When the app initially loads, FormA fills with data automatically.
Everything works fine. However, when the user closes FormA (not the
app) and reopens via the toolbar new button, the update event fires but
not the DataSourceChanged event. DataSourceChanged does fire however
for other events (for both paths to FormA). There is no difference
here. Loading FormA via new app initialization or clicking the new
button uses the same method (ShellForm.MethodA) to load the form. But,
getting to FormA in those two ways is the only difference I have found,
which doesn't say anything since nothing happens to FormA until you are
in ShellForm.MethodA.
Thanks,
Brett