Using the Project Tracker example from the book, is there way to add and show a winpart to the main form (adding it to the document listing) through a different loaded winpart (instead of from the main form)?
No, the main form has to show it so it can track the document history, etc.
But you could add a Shared/static method to the main form to allow other code to request such navigation:
Private Shared mMainForm As MainForm Public Shared Sub DisplayWinPart(ByVal part As WinPart)mMainForm.ShowWinPart(part)
End Sub
Then in Form_Load or the form's constructor just make sure to set mMainForm to Me so that reference is available and all should be well.
With this addition, any child form can create a WinPart and can request that it be displayed by calling MainForm.DisplayWinPart().
Thank you so much. I will be trying this out now.
Brian
I realize it's been a little while since I posted against this.... the code above I believe is VB, how would a person do this in C#?
Thanks again,
Exactly the same way
private static MainForm _mainForm;
public static void DisplayWinPart(WinPart part)
{
_mainForm.ShowWinPart(part);
}
If you find translating code from language to language difficult, I recommend Instant C# and Instant VB from Tangible. I've been using their product to convert C#->VB and VB->C# for months now, and it has made maintaining CSLA in both languages at least tolerable.
Given the number of excellent code examples floating in one language or the other, I strongly recommend that everyone at least learn to read both languages (it isn't like they are very different to start with). Failing that, something like Instant C# is an excellent alternative.
Copyright (c) Marimer LLC