Print Page | Close Window

For Each Control... vb net error

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=11026
Printed Date: 07 October 2024 at 8:26pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: For Each Control... vb net error
Posted By: sasa
Subject: For Each Control... vb net error
Date Posted: 13 June 2008 at 11:18am
Hi,
I don't understand where I make mistakes but a simple

    Dim Ctrl As XtremeCommandBars.CommandBarControl

    For Each Ctrl In TBar.DesignerControls
       TBar.FindControl(Ctrl.Id).Caption = "Caption"
       TBar.FindControl(Ctrl.Id).TooltipText = "TTips"
       TBar.FindControl(Ctrl.Id).DescriptionText = "aa"
    Next

return me an error in vb.net when Ctrl is an xtpControlButton.

The same source code work nice in vb6.

If I try to write...

    Dim Ctrl As XtremeCommandBars.CommandBarControl

    For Each Ctrl In TBar.DesignerControls
       Ctrl.Caption = "Caption"
       Ctrl.TooltipText = "TTips"
       Ctrl.DescriptionText = "aa"
    Next

... I have no errors but commandbar don't show new caption and tips value.
Where i make mistakes ??

Thanks to all



Replies:
Posted By: Oleg
Date Posted: 13 June 2008 at 12:12pm
Hello,
 
Use Actions to change Captions/Description easy.
 
Add CommandBars.EnableActions before you add any control and
 
CommandBars.Actions(Id).Caption = "New Caption" to change all buttons with id = "Id".
 
See Actions sample.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: sasa
Date Posted: 13 June 2008 at 1:03pm
Hello Oleg,
I receive an error NullReferenceException if I try to use method Actions.
Above there is source code:


        Dim ctrl As Control
        For Each ctrl In Me.Controls
            If TypeOf ctrl Is MdiClient Then
               cmdBarMain.SetMDIClient(ctrl.Handle.ToInt32())
            End If
        Next ctrl

        With cmdBarMain
            .LoadDesignerBars(PercorsoApp & "\MainLayout.xcb", Nothing)
            cmdBarMain(2).ModifyStyle(XtremeCommandBars.XTPCommandBarStyle.XTP_CBRS_GRIPPER, 0)

            .ActiveMenuBar.Delete()

            .Options.AlwaysShowFullMenus = True
            .Options.IconsWithShadow = True
            .Options.LargeIcons = True
            .Options.ShowExpandButtonAlways = False
            .Options.ToolBarAccelTips = True
            .Options.ToolBarScreenTips = True
            .Options.UseDisabledIcons = True
            .Options.SyncFloatingToolbars = True

            .ToolTipContext.ShowTitleAndDescription(True, XtremeCommandBars.XTPToolTipIcon.xtpToolTipIconInfo)
            .ToolTipContext.Style = XtremeCommandBars.XTPToolTipStyle.xtpToolTipBalloon
            .ToolTipContext.MaxTipWidth = 200

            .StatusBar.AddPane(0)
            .StatusBar.AddPane(1)
            .StatusBar.AddPane(2)

            .StatusBar.Font.Name = "Tahoma"
            .StatusBar.Font.Size = 10

            .StatusBar.Pane(0).Width = 180
            .StatusBar.Pane(0).Style = XtremeCommandBars.XTPStatusPaneStyle.SBPS_NOBORDERS
            .StatusBar.Pane(1).Width = 40
            .StatusBar.Pane(1).Style = XtremeCommandBars.XTPStatusPaneStyle.SBPS_NOBORDERS
            .StatusBar.Pane(2).Width = 0   ' 0 = Autro Size
            .StatusBar.Pane(2).Style = XtremeCommandBars.XTPStatusPaneStyle.SBPS_STRETCH + XtremeCommandBars.XTPStatusPaneStyle.SBPS_NOBORDERS

            .StatusBar.Pane(0).Text = "Ready to use"
            .StatusBar.Pane(1).Text = ""
            .StatusBar.Pane(2).Text = ""
            .StatusBar.Visible = True

            .EnableCustomization(False)
        End With

        cmdBarMain.Actions(ID_ANAGR).Caption = "Something"

How can I avoid problem ??

Thanks a lot


Posted By: Oleg
Date Posted: 13 June 2008 at 4:07pm
Hi,
Maybe ID_ANAGR actioin not found. Are you sure in MainLayout.xcb actions are enabled ?


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: sasa
Date Posted: 14 June 2008 at 1:42am
Hi Oleg,
I enabled actions in commandbar but it don't show me what i ask. New source code is:

        Dim ctrl As Control
        For Each ctrl In Me.Controls
            If TypeOf ctrl Is MdiClient Then
               cmdBarMain.SetMDIClient(ctrl.Handle.ToInt32())
            End If
        Next ctrl

        With cmdBarMain
            .LoadDesignerBars(PercorsoApp & "\MainLayout.xcb", Nothing)

            .EnableActions()

            cmdBarMain(2).ModifyStyle(XtremeCommandBars.XTPCommandBarStyle.XTP_CBRS_GRIPPER, 0)

            .ActiveMenuBar.Delete()

            .Options.AlwaysShowFullMenus = True
            .Options.IconsWithShadow = True
            .Options.LargeIcons = True
            .Options.ShowExpandButtonAlways = False
            .Options.ToolBarAccelTips = True
            .Options.ToolBarScreenTips = True
            .Options.UseDisabledIcons = True
            .Options.SyncFloatingToolbars = True

            .ToolTipContext.ShowTitleAndDescription(True, XtremeCommandBars.XTPToolTipIcon.xtpToolTipIconInfo)
            .ToolTipContext.Style = XtremeCommandBars.XTPToolTipStyle.xtpToolTipBalloon
            .ToolTipContext.MaxTipWidth = 200

            .EnableCustomization(False)
        End With

        cmdBarMain.Actions.Add(ID_ANAGR, "CaptionAction", "tooltip action", "descr action", Nothing)
        cmdBarMain.Actions(ID_ANAGR).Caption = "NewCaption"
        Dim test As String = cmdBarMain.Actions.Action(ID_ANAGR).Caption

in such way, it change Caption property but new caption is not showed when I run program.

Where I'm wrong ??


Posted By: Oleg
Date Posted: 14 June 2008 at 5:16am

Hi,

Actions have to be enabled in MainLayout.xcb. Open it in designer, select some controls and in propertyPages click "Enable Actions"


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: sasa
Date Posted: 14 June 2008 at 5:44am
Thanks... thanks.... thanks.
Now it work nice. Thank you very much Oleg

Have a nice day


Posted By: Oleg
Date Posted: 15 June 2008 at 8:19am
:)

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net