From a ESRI.ArcGIS.Desktop.AddIns.Button, I would like to get the list box from the dockable window; see below. Where in the dockable window code can I set the User Data property? Is this the correct approach?
protected override void OnClick()
{
IDockableWindowManager dockWindowManager = ArcMap.DockableWindowManager as IDockableWindowManager;
if (dockWindowManager != null)
{
UID windowID = new UIDClass();
windowID.Value = "DocWin";
IDockableWindow docWin = dockWindowManager.GetDockableWindow(windowID);
if (docWin.IsVisible())
{
docWin.Show(false);
}
else
{
docWin.Show(true);
}
System.Windows.Forms.ListBox containedBox = docWin.UserData as System.Windows.Forms.ListBox;
if (containedBox != null) containedBox.Items.Add("Test 1");
}
}
---------------
Docable window class code
/// <summary>
/// Designer class of the dockable window add-in. It contains user interfaces that
/// make up the dockable window.
/// </summary>
public partial class DocWin : UserControl
{
public DocWin(object hook)
{
InitializeComponent();
this.Hook = hook;
}
/// <summary>
/// Host object of the dockable window
/// </summary>
private object Hook
{
get;
set;
}
/// <summary>
/// Implementation class of the dockable window add-in. It is responsible for
/// creating and disposing the user interface class of the dockable window.
/// </summary>
public class AddinImpl : ESRI.ArcGIS.Desktop.AddIns.DockableWindow
{
private DocWin m_windowUI;
public AddinImpl()
{
}
protected override IntPtr OnCreateChild()
{
m_windowUI = new DocWin(this.Hook);
return m_windowUI.Handle;
}
protected override void Dispose(bool disposing)
{
if (m_windowUI != null)
m_windowUI.Dispose(disposing);
base.Dispose(disposing);
}
}
}