ms word - How to Expose Listbox in UserControl in CustomTaskPane VSTO C# -
i creating application level add-in word 2010 using c# vsto. created user control, placed controls within it, , used user control add custom task pane:
usercontrol myusercontrol; myusercontrol = new pageelementspane(); mytaskpane = this.customtaskpanes.add (myusercontrol, "page elements", doc.activewindow); so far good. however, user control contains listbox have not been able access after custom task pane added custom task pane collection.
i have tried setting modifiers property on listbox public. have tried exposing listbox on user control public property:
public partial class pageelementspane: usercontrol { public listbox elementspanelistbox { { return lbxlistbox; } } } additionally, looked @ post:
working listbox elements in user control
i hoped adapt it, listbox intellisense not have findcontrol, offering findform instead. there way access listbox within user control somehow interpreting custom task pane form? appreciated.
it appears foreach (and hence cast) not correct (per eugene astafiev's question in comment above). found so post suggesting looping type control instead of usercontrol. did , good. here code:
foreach (control lbxcontrol in myusercontrol.controls) { if (lbxcontrol listbox) { ((listbox)lbxcontrol).selectedindex = 1; } }
Comments
Post a Comment