TaskDialogStandardIcon 在任务对话框中不起作用

Posted

技术标签:

【中文标题】TaskDialogStandardIcon 在任务对话框中不起作用【英文标题】:TaskDialogStandardIcon not working on task dialog 【发布时间】:2013-03-26 19:18:57 【问题描述】:

我正在 vb.net 中创建一个任务对话框,但图标没有出现。(其他一切正常)我正在使用 Microsoft.WindowsAPICodePack.Dialogs。我的代码如下:

 Dim commandLink_Send = New TaskDialogCommandLink("btnShowAlternatives", "View Alternative Times", "Select an available time")
    Dim commandLink_Ignore = New TaskDialogCommandLink("buttonIgnore", "Go Back", "Go back to booking form")
    **td.Icon = TaskDialogStandardIcon.Shield**
    td.Caption = "Application Error"
    td.InstructionText = "Booking ***"
    td.Text = "The application has found a *** in one more of the selected resources"
    td.Cancelable = False
    td.Controls.Add(commandLink_Send)
    td.Controls.Add(commandLink_Ignore)
    AddHandler commandLink_Send.Click, AddressOf eventHandlers.commandLink_send_click
    AddHandler commandLink_Ignore.Click, AddressOf eventHandlers.commandLink_ignore_click

我做错了什么

干杯

【问题讨论】:

【参考方案1】:

目前,只有 1 种解决方法。 您需要从 Opened 事件调用中设置它。 像这样的:

AddHandler yourTD.opened, AddressOf yourTD_Opened

在某处添加如下内容:

Private Shared Sub yourTD_Opened(ByVal sender As Object, ByVal e As System.EventArgs)
    yourTD.icon = TaskDialogStandardIcon.Shield
    'And if you prefer you could also
    'yourTD.FooterIcon = TaskDialogStandardIcon.whichevericonyouwant
End Sub

干杯。

【讨论】:

如果你像我一样来这里寻找 c# 代码:taskDialog.Opened += delegate taskDialog.Icon = TaskDialogStandardIcon.Error; ;

以上是关于TaskDialogStandardIcon 在任务对话框中不起作用的主要内容,如果未能解决你的问题,请参考以下文章