Updating a WiX UI ListBox using DTF


By using Deployment Tools Foundation (DTF) which is now part of WiX, a listbox (or other control) can be updated in a much cleaner way via a Custom Action (CA) than it would otherwise have been achieved. The following code snippet shows how direct access to a ListBox control can be gained to add a record to it.

try
{
    session.Log("Begin Configure EWS Filter Custom Action");
    //Debugger.Launch();

    Database db = session.Database;
    string sqlInsertTemp = db.Tables["ListBox"].SqlInsertString + " TEMPORARY";
    View view = db.OpenView(sqlInsertTemp);
    view.Execute(new Record(new object[] { "LISTBOXVALUES", 1, "1", "One" }));
    view.Close();

    session.Log("End Configure EWS Filter Custom Action");
}
catch (Exception ex)
{
    session.Log("ERROR in custom action ConfigureEwsFilter {0}",
            ex.ToString());
    return ActionResult.Failure;
}

, , , , ,

  1. No comments yet.
(will not be published)