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
85
Exception "Can't activate a tool that is not visible." when trying to activate TextBoxTool in Ribbon
posted

I have a windows form with a UltraToolbarsManager containing a ribbon with groups, tools and a textboxtool. I want the textboxtool to get the focus when F12 is pressed but i am getting the exception "Can't activate a tool that is not visible."

I searched the forum and found some old entry but i could not get a solution out of it.

The Code i am running is:

Private Sub frmMain_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp

If e.KeyCode = Keys.F12 Then

zeigeofrmBueroKunden()

oUltraToolbarsManagerMain.Ribbon.SelectedTab = oUltraToolbarsManagerMain.Ribbon.Tabs("buero")

Dim oTextBoxTool As TextBoxTool = CType(oUltraToolbarsManagerMain.Ribbon.Tabs("buero").Groups("BueroKunden").Tools("BueroKundenSuchenTextBoxTool"), TextBoxTool)
oTextBoxTool.IsActiveTool = True

e.Handled = False
End If
End Sub

Parents
No Data
Reply
  • 12480
    Verified Answer
    Offline posted

    Hi Dawit,

    The reason that this doesn't work is because setting a tool that isn't visible to be the active tool is not allowed. In this case, the tool you're setting will be active next time the page draws. The simplest way to address this, then, is to call Me.Update() to force the screen to draw.

    An alternate solution is to use Invoke to defer setting the active tool until the next time messages are processed.

    Please try this out and let me know which solution works for you.

Children