1
正在創建VS Outlook外接程序。VSTO功能區組合框文本更改事件回調
如何獲取組合框的文本更改事件。我想打電話給我的API來獲取數據,而用戶在組合框中
<comboBox id="cmbUsers" label="Users" showImage="false"
getItemCount="OnGetItemCount"
getItemLabel="OnGetItemLabel"
onChange="OnChange"
getText="GetText"
getKeytip="GetKeytip"/>
我的OnChange呼叫試圖回輸入一些文字,但它不能正常工作。但是在Ribbon Designer中我可以看到TextChange事件。
如何使用回調事件的文字變化
[ComVisible(true)]
public class Ribbon : Office.IRibbonExtensibility
{
private Office.IRibbonUI ribbon;
public Ribbon()
{
}
#region IRibbonExtensibility Members
public string GetCustomUI(string ribbonID)
{
return GetResourceText("UserOutlookAddin.Ribbon.xml");
}
#endregion
#region Ribbon Callbacks
//Create callback methods here. For more information about adding callback methods, select the Ribbon XML item in Solution Explorer and then press F1
public void Ribbon_Load(Office.IRibbonUI ribbonUI)
{
this.ribbon = ribbonUI;
}
public void OnActionCallback(Office.IRibbonControl control)
{
if (control.Id == "checkBox1")
{
MessageBox.Show("You clicked " + control.Id);
}
else
{
MessageBox.Show("You clicked a different control.");
}
}
public void OnGetItemCount(Office.IRibbonControl control)
{
Debug.WriteLine("##### Am OnGetItemCount");
}
public void OnGetItemLabel(Office.IRibbonControl control)
{
Debug.WriteLine("##### Am OnGetItemLabel");
}
public void OnChange(Office.IRibbonControl control)
{
Debug.WriteLine("##### Am OnChange");
}
public void GetText(Office.IRibbonControl control)
{
Debug.WriteLine("##### Am GetText");
}
public void GetKeytip(Office.IRibbonControl control)
{
Debug.WriteLine("##### Am GetKeytip");
}
#endregion
#region Helpers
private static string GetResourceText(string resourceName)
{
Assembly asm = Assembly.GetExecutingAssembly();
string[] resourceNames = asm.GetManifestResourceNames();
for (int i = 0; i < resourceNames.Length; ++i)
{
if (string.Compare(resourceName, resourceNames[i], StringComparison.OrdinalIgnoreCase) == 0)
{
using (StreamReader resourceReader = new StreamReader(asm.GetManifestResourceStream(resourceNames[i])))
{
if (resourceReader != null)
{
return resourceReader.ReadToEnd();
}
}
}
}
return null;
}
#endregion
}
你可以發佈有關'OnChange' C#代碼? – haindl
@haindl是的,我現在更新 –