简体   繁体   中英

How to delete selected item from listbox in wix installer using custom action

I have following code of custom action which delete's all item from the listbox. But, I need to delete selected item from listbox.

    [CustomAction]
    public static ActionResult RemoveListItem(Session session)
    {
        try
        {
            Microsoft.Deployment.WindowsInstaller.View View = session.Database.OpenView("DELETE FROM ListBox WHERE ListBox.Property='LIST_ITEM'");
            View.Execute();
        }
        catch (Exception ex)
        {
            return ActionResult.Failure;
        }
        return ActionResult.Success;
    }

Please help me solve this issue.

you need to pass id of the item that you want to delete from listbox. after that put that id on your query.

public static ActionResult RemoveListItem(Session session, int Id)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM