Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2114
Adding a imageList toolbar selector in a Winforms Toolbar
posted

 

Hello,

 

I need to add a simple selection in the infragistics toolbar:


(x) APicture AText

     BPicture BText

     CPicture CText

 

My problem is that when I builmd the Toolbar, I have no acces to the toolbars manager, to do this:

' Adds the tool to the Toolbar Manager's Tools collection
        Me.UltraToolbarsManager1.Tools.Add(popupmenutool)
        Me.UltraToolbarsManager1.Toolbars(0).Tools.Add(popupmenutool)
 
        Me.UltraToolbarsManager1.Tools.Add(listtool)
        Me.UltraToolbarsManager1.Toolbars(0).Tools.Add(listtool)

 

 

I have a separate function that dinamically builds a Toolbar using some parameters, and it works for all paramètres but list:

 

  Public Function GetCustomToolbar(ByVal name As String, ByVal ParamArray params() As ToolInfo) As Infragistics.Win.UltraWinToolbars.UltraToolbar

    Dim UltraToolbar1 As New Infragistics.Win.UltraWinToolbars.UltraToolbar(name)

 

    UltraToolbar1.Settings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False

    UltraToolbar1.Settings.AllowDockLeft = Infragistics.Win.DefaultableBoolean.False

    UltraToolbar1.Settings.AllowDockRight = Infragistics.Win.DefaultableBoolean.False

    UltraToolbar1.Text = name

 

    'Dim myButtonTool As Infragistics.Win.UltraWinToolbars.ButtonTool

    'Dim myLabelTool As Infragistics.Win.UltraWinToolbars.LabelTool

    'Dim myStateButtonTool As Infragistics.Win.UltraWinToolbars.StateButtonTool

    'Dim myControlContainerTool As Infragistics.Win.UltraWinToolbars.ControlContainerTool

    Dim myListTool As Infragistics.Win.UltraWinToolbars.ListTool

    Dim myPopupMenuTool As Infragistics.Win.UltraWinToolbars.PopupMenuTool

 

    Dim tools As New List(Of ToolBase)

 

    For Each info As ToolInfo In params

      Select Case info.Type

        'Case CustomToolType.Button

        '  Dim bInfo As ToolButtonInfo = DirectCast(info, ToolButtonInfo)

        '  myButtonTool = New Infragistics.Win.UltraWinToolbars.ButtonTool(bInfo.Id)

        '  myButtonTool.CustomizedCaption = info.Tooltip

        '  myButtonTool.CustomizedImage = bInfo.Picture

        '  myButtonTool.InstanceProps.IsFirstInGroup = info.IsFirstInGroup

        '  tools.Add(myButtonTool)

 

        'Case CustomToolType.CustomControl

        '  Dim cInfo As ToolCustomControlInfo = DirectCast(info, ToolCustomControlInfo)

        '  myControlContainerTool = New Infragistics.Win.UltraWinToolbars.ControlContainerTool(cInfo.Id)

        '  myControlContainerTool.Control = cInfo.Control

        '  myControlContainerTool.InstanceProps.IsFirstInGroup = info.IsFirstInGroup

        '  tools.Add(myControlContainerTool)

 

        'Case CustomToolType.Label

        '  Dim lInfo As ToolLabelInfo = DirectCast(info, ToolLabelInfo)

        '  myLabelTool = New Infragistics.Win.UltraWinToolbars.LabelTool(info.Id)

        '  myLabelTool.InstanceProps.IsFirstInGroup = info.IsFirstInGroup

        '  myLabelTool.CustomizedCaption = lInfo.Caption

        '  tools.Add(myLabelTool)

 

        'Case CustomToolType.StateButton

        '  Dim sbInfo As ToolStateButtonInfo = DirectCast(info, ToolStateButtonInfo)

        '  myStateButtonTool = New Infragistics.Win.UltraWinToolbars.StateButtonTool(sbInfo.Id)

        '  myStateButtonTool.CustomizedCaption = info.Tooltip

        '  myStateButtonTool.CustomizedImage = sbInfo.Picture

        '  myStateButtonTool.InstanceProps.IsFirstInGroup = info.IsFirstInGroup

        '  myStateButtonTool.Checked = sbInfo.Checked

        '  myStateButtonTool.MenuDisplayStyle = StateButtonMenuDisplayStyle.DisplayToolImage

        '  tools.Add(myStateButtonTool)

 

        Case CustomToolType.List

          Dim listInfo As ToolListInfo = DirectCast(info, ToolListInfo)

          myPopupMenuTool = New Infragistics.Win.UltraWinToolbars.PopupMenuTool(listInfo.Id)

          myListTool = New Infragistics.Win.UltraWinToolbars.ListTool(listInfo.Id + "List")

          myListTool.CustomizedCaption = listInfo.Tooltip

 

          For Each item As cllTools.Troika(Of String, String, Image) In listInfo.Items

            Dim listItem As New ListToolItem(item.Left, item.Center, False)

            listItem.Appearance.Image = item.Right

            myListTool.ListToolItems.Add(listItem)

          Next item

 

          myListTool.InstanceProps.IsFirstInGroup = info.IsFirstInGroup

          myListTool.DisplayCheckmark = False

 

          myPopupMenuTool.Tools.AddTool((myListTool.Key) ' EXCEPTION HERE!!!!!!!!!!!

 

          tools.Add(myPopupMenuTool)

      End Select

 

    Next info

 

    UltraToolbar1.Tools.AddRange(tools.ToArray())

 

    Return UltraToolbar1

  End Function

 

 

What to do ?