CAB logic issue

Topics: CAB & Smart Client Software Factory
May 9, 2007 at 1:08 AM
Hello,
I´am a CAB logic question.
I have a solution based in CAB, i develop a smartpart who has a datagrid to display data from a Dataset.
I have a lot of "use case" in my solution who use this smartpart.
Now i develop an other smartpart to choose an interval of date, and i want to use Event broker to tell, the Datagrid to update the data. But i have a lot of instance created of this "Datagrid" smartpart ! how can i reach the instance of this datagrid where i want to change the interval of dates.
The instance of my smartpart where i choose the interval of dates is the same to severals instances of my datagrid smartparts placed in a TabedWorkspace.
When i create an instance of the smartpart containing the datagrid i use the coleccion items of the module workitem to know and request the good dataset with the goods parameters, but i delete each time the item.
How can i perform the update of the good datagrid via event broker ?

thanks for your response, i hope my explanation was clear.
May 9, 2007 at 7:36 AM
I guess it's not quite clear, what instance of your many DataGrids you want to update from DateTime picker. Is it an active tab on TabedWorkspace?

I think in this case DateTime picket should fire an event anyway - telling that the user has chosen a new time interval and all DataGrids should catch this event, but each DataGrid instance should decide itself how to react on this event. Maybe if DataGrid is an active tab at this moment it should update data and the others will just do nothing because they are not active.

-
Thanks,
Leonid
May 9, 2007 at 3:44 PM
Yes LeonidShimarov, it´s exactly wat i want.
Update the active instance of my datagrid smartpart in the tabedworksspace.
So if i understand :
- The DateTimePicker smartpart fire the changedate event and the datagrid smartpart subcribe this event, but the action of update the data is only perform if the instance of the smartpart Datagrid is active in the tabedWorkspace.

I´am right ? How can i determine if the view is active in the TabedWorkspace. ?

- How can i pass two DateTime arguments in the event. I was searching in old post and i find that i need to use the
DataEventArgs class but i need to write another custom DataEventArgs class ?
{{public event EventHandler<DataEventArgs<DateTime>> ChangeDateInterval; }} Thank you very much for your help.
May 9, 2007 at 5:13 PM
workspace.ActiveSmartPart will give you the active view in any workspace.

This is a common problem in CAB (detecting the "active" view and having it respond to an event while other instances of the same view do not). We solved this where I work in a pretty slick way; I'm writing a blog post on it with a sample application. I hope to have it done today. Will keep you posted.

-Chris
May 9, 2007 at 5:25 PM
Thanks Chris, I wait for your sample.
May 10, 2007 at 8:01 PM

danisam wrote:
- How can i pass two DateTime arguments in the event. I was searching in old post and i find that i need to use the
DataEventArgs class but i need to write another custom DataEventArgs class ?
{{public event EventHandler<DataEventArgs<DateTime>> ChangeDateInterval; }}

You can create your own Event Args Class that inherit EventArgs.

Public class DateRangeEventArgs:EventArgs
{
 
private DateTime _StartDate;
private DateTime _EndDate;
 
public DateRangeEventArgs(DateTime startDate,DateTime endDate)
{
_StartDate = startDate;
_EndDate = endDate;
}
 
public DateTime StartDate
{
get {return _StartDate;}
set {_StartDate = value;}
}
 
public DateTime EndDate
{
get {return _EndDate;}
set {_EndDate = value;}
}
 
 
}
 

And you use it like any eventargs.

Hope that helps you,
Jordon