Dropping SmartPart into Workspace

Topics: CAB & Smart Client Software Factory
Sep 8, 2006 at 2:51 PM
originally posted by: hbpost

Has anyone been able to drop a SmartPart from the Toolbox onto a Workspace at design time? The SCSF documentation says this can be done, but I get a NullPointerException in View's OnLoad event, where I expect the Presenter has not been properly injected.


Herman Post
Sep 12, 2006 at 11:27 AM
originally posted by: hbpost

OK - the silence is killing me.

Is this just a dumb question that is not worthy of a response?

Is it something no one cares about or has tried?

Is it a bug or unimplemented feature?

I'd love to hear from someone - Microsoft?

Thanks again,

Herman Post
Sep 12, 2006 at 6:57 PM
originally posted by: DapinderSingh

Hi hbpost,

No this is not a dumb question at all. lets ge to the solution first

As per ur mail, i understood that you have created a solution in which teh first project ( lets name it project A) contains smart part ( user controls) and the other project (lets name it project B) is the shellApplication ( with winforms). Now ur requirement is that you should be able to drop the controls created in project A on the form of project B.

If this is what you want to do, then here are the instructions

1. Open the form of shell application in design view.
2. Open the toolbox view and right click on the tool box view. From the conext menu of the toolbox menu, select choose items and then browse for the assembly( dll) of project A, select the aseembly and select OK.
3. This will add all the smart parts in the tool box control.
4. Now u can drag and drop the samrt parts on the form.

IMPORTANT: Open the code page of this form ( lets say form1.cs) and add this code before InitializeComponent () function.

if (this.DesignMode == false)

In case you still have problems, just mail.
Sep 14, 2006 at 10:26 AM
originally posted by: hbpost

Thanks for responding. You have described what I would like to do accurately, but it still does not seem to work.

It fails in the View.OnLoad method. I am guessing the the Presenter class has not been successfully injected into the View at this point. It seems that the DesignSurface would have to be aware of CAB for this to work. I would also expect it to generate code in the ModuleController.AddViews to show the SmartPart.
Sep 14, 2006 at 8:59 PM
originally posted by: DapinderSingh

Are you using the guidance package ?
Sep 15, 2006 at 6:12 AM
originally posted by: hbpost

Yes - standard SCSF project. Does this work for you?
Sep 18, 2006 at 7:13 PM
originally posted by: DapinderSingh

Yes, that does the work for me.
You can do one thing, create a blank project using SCSF and then in the module dll add one user control. Add the SmartPart tag in the user control class and the build this dll.

now add this dll in the tool bar and on the shellform, try to drop the the smartpart with the 2 lines iof code I mentioned in my previous drop.

It should work. Incase if it dosen't, do let me know.
Sep 19, 2006 at 6:43 AM
originally posted by: hbpost

If I do exactly what you say it will work, but this is not what I want to do. The help from SCSF states the following:

"If you know the location at design time, you can drag the SmartPart into a suitable workspace to achieve the required layout of the form contents. For example, you can use a TabWorkspace or a ZoneWorkspace."

I don't think the intent of this is to merely put the SmartPart attribute on a UserControl. I believe the intent is that you can create a new BusinessModule and add a new View to it using the SCSF recipe. This generates a SmartPart View and Presenter. It is this SmartPart that you should be able to drop onto a Workspace.

It seems to me that the whole point of CAB is that Microsoft is saying "this is a better component model". In the past we have worked with UserControl as a black box component, and it has worked pretty well. But the problem with UserControl is all of your business logic and controller logic ends up coupled to the View. CAB implements better design patterns. The 'components' generated by CAB - Workitems,Controllers, MVP - are the new component model.

One should be able to distribute SCSF generated Modules and place the SmartParts from those Modules in the Toolbox and manipulate them at design time.

It would be nice to hear from Microsoft or others on this. Is this the intent?


Herman Post