CAB statechanged issue

Topics: CAB & Smart Client Software Factory
Jul 21, 2007 at 11:28 PM
Edited Jul 21, 2007 at 11:29 PM
Iam having problems with the state changed event.
i am trying to implement similar to the link below.
http://luifit.net/blogs/jluif/CommentView,guid,8cf9a782-d629-4f49-ac9b-6d22c8ae9598.aspx

my bindingSource.datasource in the View gets updated before i try to update it from the presenter.
it gets updated once i initialize the workitem.state[]...

I am not sure where am i going wrong...

my Presenter code is as follows: (presenter)

public void SelectedWellChanged(string wellID, string wellCD)
{
this.WorkItem.StateWellDataWorkItem.WELL_STATE = wellService.GetWellHeaderData(wellID, wellCD);
}

StateChanged(WellDataWorkItem.WELL_STATE , ThreadOption.Publisher)
public void TreeSelectionChanged(object sender, StateChangedEventArgs args)
{
WellDataDTO wellDt = args.NewValue as WellDataDTO;
UpdateWellDataSource(wellDt);
}


public override void UpdateWellDataSource(WellDataDTO wh)
{
this.View.WellHeaderDataSource = wh;
}

my View code is as follows: (view)

public WellDataDTO WellHeaderDataSource
{
set {
this.wellHeadBindingSource.DataSource = value;
}
}

private void tvWell_AfterSelect(object sender, TreeViewEventArgs e)
{
TreeNode tn = tvWell.SelectedNode;
if (tn.Tag.ToString().IndexOf("WellID") >= 0)
{
this.presenter.SelectedWellChanged(tn.Tag.ToString().Substring(11, tn.Tag.ToString().Length - 11), tn.Tag.ToString().Substring(9, 2));
}

when the app runs for the first time everything is good.
I have a tree view. on selecting a different tree node i trigger the presenter.SelectedWellChanged
after running the next statement
this.WorkItem.StateWellDataWorkItem.WELL_STATE = something..

my views bindingsource.datasource is already changed.. to that something before the state changed event triggers...

The textboxes in the view which are binded to the bindingsource do not get refreshed?

can anyone explain me whats going wrong...
Jul 22, 2007 at 2:30 AM
Sounds like a threading issue. What happens if you change ThreadOption.Publisher to ThreadOption.UI?
Jul 23, 2007 at 2:41 PM
Edited Jul 23, 2007 at 3:47 PM
In the stateElement.cs file in CompositUI

the RaiseStateChanged(key, value, oldvalue) event ;
value and oldvalue are same always except for the first call.
i am not sure how the old value is changing to this new value.
Jul 23, 2007 at 3:33 PM

sefstrat wrote:
Sounds like a threading issue. What happens if you change ThreadOption.Publisher to ThreadOption.UI?

I changed the thread option. No change. still it is the same. i have no idea where i am going wrong.
Jul 23, 2007 at 6:32 PM

coolsumit wrote:
In the stateElement.cs file in CompositUI

the RaiseStateChanged(key, value, oldvalue) event ;
value and oldvalue are same always except for the first call.
i am not sure how the old value is changing to this new value.


I think the problem is with the bindingsource.datasource not the statechange.
i still need to figure our why bindingsource.datasource is getting updated...