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 ?
Hello serhiol,
I am checking about the progress of this issue. Please let me know If you need any further assistance on this.
I got very confused by your last post. What I understood from it is that you want to have such toolbar without having an 'UltraToolbarsManager' component, is that right? If so, this is very unusually requirement, since the component is the one which provides such functionality.
Boris, the CustomToolType is an enumeration, but is not relevant to the problem.
Did you read my previous post till end?
I need just to have an ImageList toolbar, like above, without dealing with the toolbar manager, cause I have no access to it in that function.
Hello serhio,
I am still getting some errors about 'CustomToolType'. If you do not want to provide the big application, you could paste the code that you are giving me here in a new project and see for yourself what will I need in order to run the sample and assist you further on that matter.
Hello, Boris.
ToolInfo is a custom class something like this
Public MustInherit Class ToolInfo Public Tooltip As String Public Id As String Public Type As CustomToolType Public IsFirstInGroup As Boolean Public Sub New(ByVal id As String, ByVal tooltip As String, ByVal type As CustomToolType, Optional ByVal isFirstInGroup As Boolean = False) Me.Tooltip = tooltip Me.Id = id Me.Type = type Me.IsFirstInGroup = isFirstInGroup End Sub End Class Public Class ToolButtonInfo Inherits ToolInfo Public Picture As Image Public Sub New(ByVal id As String, ByVal tooltip As String, ByVal type As CustomToolType, ByVal picture As Image, Optional ByVal isFirstInGroup As Boolean = False) MyBase.New(id, tooltip, type, isFirstInGroup) Me.Picture = picture End Sub End Class
I have no sample, because I have a big application, but, ok, I precise some thing to be more explicit:
I have a base Form that contains a (private) ToolbarManager.
Every inherited Form returns its own list of Toolbar (the method GetCustomToolbar above), so, inherited forms have no acces to the Manager.