The last two days I have been busy developing a POC for a local financial company here in Belgium. The goal was to demonstrate how one can push financial information (info on your accounts and the bank transactions associated with them) into the Office environment. We picked Excel as the host environment and created a smart document using the Vertigo Smart Document Wrapper. I love this wrapper. It hides most of the plumbings of creating a smart document solution. The behavior of a smart document however is not quite that of a normal Windows application. For example, we have the following interface where first a drop down is filled up with all your bank names and then after selecting a bank name, the account numbers are displayed.

Very easy to do in a Windows form with the implementation of the correct event handler. In a smart document however it is a bit more difficult. One of the things that is hard to do for example within an event handler is the access of another control. For example, in the event handler for the first drop down, access the the second drop down  control. I thought it might be useful to share this info here for all you would-be smart document developers :-).

In your configuration.xml (location in the Vertigo Smart Document project where you define the controls to be displayed) we have the two definitions of the dropdowns.

<Control Caption="Selecteer een bank service" Name="Combo_BankService" Type="C_TYPE_COMBO" OnPreRender="FillBankServices" OnAction="StoreBank">Control>

<Control Caption="Selecteer een bank rekening" Name="Combo_BankAccount" Type="C_TYPE_COMBO" OnPreRender="DisplayBankAccounts" OnAction="FillDetails">Control>


So, when a bank is selected, the FillBankAccounts procedure is executed. Remember, you cannot simply communicate with the second drop down in that procedure. That is why you simply store the selected bank in a class-level variable.

public void StoreBank(object sender, ActionEventArgs e)
{
  this._bankService = e.Value;
  this._workbook.SmartDocument.RefreshPane();
}

Notice the second line where I use the RefreshPane method of the SmartDocument. This causes all the OnPreRender actions to be executed. Think of it as an ASP.NET post-back you have done. So in the PreRender of the first drop down you have to check a bit in the same way as in ASP.NET to see you have a post-back yes or no. In the PreRender of the second one, we then go back to the back-end and retrieve the list of bank accounts for the selected bank of which we find the name in the local class variable.

public void DisplayBankAccounts(object sender, PreRenderEventArgs e)
{
    //-- omitted block with call to Web service
    //-- accounts is local variable with array of accounts
   if(accounts!=null)
   {
     e.ListItems = accounts;
   }
}

Another example where you use this approach is a text box where the user enters a value and a button where you perform a certain operation using that value.

Hope this is helpful to some of you readers. If there are other approaches to this let us know!