从另一个控件的回调中更新iRibbon控件的内容 [英] Updating contents of an iRibbon control from another control's callback

查看:40
本文介绍了从另一个控件的回调中更新iRibbon控件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VBA的早期,我们曾经能够直接通过名称访问表单上的控件.我对如何在VBA 2010中执行此操作感到困惑(或者甚至不再可能).

Back in the old days of VBA, we used to be able to directly access controls on a form by name. I'm a little perplexed by how to do this in VBA 2010 (or if it's even possible any longer).

说我有一个功能区控件,其中包含一个名为"channelList"的下拉列表,在功能区上的其他地方,我有一个名为"labelText"的文本框.每个项目都有一个独特的回调函数-当我在labelText中键入内容时,其回调将触发,而当我从channelList列表框中选择一个项目时,其回调将使用作为参数传递的列表项目触发.

Say I have a ribbon control with a dropdown list called "channelList", and elsewhere on the ribbon I have a textbox called "labelText". Each of these items has a unique callback function - when I type something into labelText, its callback fires, and when I select an item from the channelList listbox, its callback fires with the list item passed as an argument.

困扰我的是如何在channelList回调中使用"something"更新labelText文本框的内容.

Where I'm stumped by is how I would update the labelText textbox contents with 'something' from within the channelList callback.

是否可以从列表框回调中直接访问文本框控件,还是必须生成某种事件?我将使用什么方法或函数来设置控件的文本值?(我需要将IRibbonControl对象转换为某些对象吗?)

Is there a way to directly access the textbox control from within the listbox callback, or must I generate some sort of event? What method or function would I use to set the text value for the control? (Do I need to cast the IRibbonControl object to something?)

推荐答案

解决方案是答案和注释的组合,所以去了:

The solution was a combination of an answer and the comments, so here goes:

  • 向Ribbon XML添加"getText"回调子例程名称,特定于"labelText"编辑框.

    editBox id="labelText" label="Text:" sizeString="xxxxxxxxxx"
    onChange="TextboxCallback" getText="UpdateTextBoxText"
    screentip="Channel label"
    supertip="Limited to 10 characters. Press Enter once finished typing." 

  • 在组合框回调函数中,将所需的编辑框文本设置为全局文本,然后使用"labelText"作为参数调用Ribbon.InvalidateControl.
  • 
        MyRibbon.InvalidateControl "labelText"
    

    • 实施editbox回调,将一个句柄传递给功能区,并将另一个变量ByRef传递给包含要更新的东西".使用全局变量通过ByRef参数更新控件的文本.
    • 
          Sub UpdateTextBoxText(control As IRibbonControl, ByRef returnedVal)
          Select Case (control.id)       
              Case "labelText"
                  returnedVal = LabelText
          End Select
          End Sub
      

      我想这是进步".labelText.Value ="blah"太简单了.

      I guess this is "progress". labelText.Value = "blah" is far too simple.

      这篇关于从另一个控件的回调中更新iRibbon控件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆