public DSM_Toolbar() { // // TODO: Define your toolbar here by adding items // AddItem("DSM_DocumentManager.DocumentManager"); AddItem("DSM_Symbology.Symbology"); AddItem("DSM_QCTool.QCTool"); BeginGroup(); //Separator AddItem("DSM_CalcMetric.CalcMetric"); AddItem("DSM_GIFAngle.GIF_Angle"); AddItem("DSM_Attribute_Update.AttributeUpdater"); //The ComboBox ComboBox combo = new ComboBox(); combo.Items.Add("25"); combo.Items.Add("50"); AddItem(combo); //this wont work though....how do I do this??? }
One more quick question. I have some Tools that when I click them, I need to change the SelectedItem in the ComboBox from the OnClick event of the tool. How do I access the ComboBox from the Tool?? I've set the Modifiers of the ComboBox to public, but I can't seem to get to it.
Hi James,Thanks for the Panel tip. That worked perfectly and was very easy to implement. The method I am doing this with is the same as yours....using a UserControl.Thanks!!
Thanks for the responses. I've implemented a solution based on jmhauck's posting. I'm noticing one strange thing though. Initially the toolbar opens up fine and everything is visible. But once I start an edit session, the combobox dissapears. It is still there, you just can't see it. If you click on where the control should be, it then appears and you can select from the drop down list, and use it normally.Why is it dissapearing when I start an edit session??
using System; using System.Drawing; using System.Runtime.InteropServices; using ESRI.ArcGIS.ADF.BaseClasses; using ESRI.ArcGIS.ADF.CATIDs; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.SystemUI; namespace DSM_ServiceConnection_Toolbar { /// <summary> /// Summary description for DiametersComboBoxToolCtrl. /// </summary> [Guid("135e9481-2245-4411-866b-de687b51c512")] [ClassInterface(ClassInterfaceType.None)] [ProgId("DSM_ServiceConnection_Toolbar.DiametersComboBoxToolCtrl")] public sealed class DiametersComboBoxToolCtrl : BaseCommand, IToolControl { #region COM Registration Function(s) [ComRegisterFunction()] [ComVisible(false)] static void RegisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryRegistration(registerType); // // TODO: Add any COM registration code here // } [ComUnregisterFunction()] [ComVisible(false)] static void UnregisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryUnregistration(registerType); // // TODO: Add any COM unregistration code here // } #region ArcGIS Component Category Registrar generated code /// <summary> /// Required method for ArcGIS Component Category registration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryRegistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); MxCommands.Register(regKey); } /// <summary> /// Required method for ArcGIS Component Category unregistration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryUnregistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); MxCommands.Unregister(regKey); } #endregion #endregion private IHookHelper m_hookHelper = null; private DiametersComboBoxCtrl m_diametersComboBoxCtrl = null; //private IApplication m_application; public DiametersComboBoxToolCtrl() { // // TODO: Define values for the public properties // base.m_category = "DSM Service Connection Tools"; //localizable text base.m_caption = "Diameters ComboBox"; //localizable text base.m_message = ""; //localizable text base.m_toolTip = ""; //localizable text base.m_name = "Diameters ComboBox"; //unique id, non-localizable (e.g. "MyCategory_ArcMapCommand") try { // // TODO: change bitmap name if necessary // string bitmapResourceName = GetType().Name + ".bmp"; base.m_bitmap = new Bitmap(GetType(), bitmapResourceName); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap"); } } #region Overriden Class Methods /// <summary> /// Occurs when this command is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { if (hook == null) return; if (m_hookHelper == null) m_hookHelper = new HookHelperClass(); m_hookHelper.Hook = hook; //make sure that the usercontrol has been initialized if (null == m_diametersComboBoxCtrl) { m_diametersComboBoxCtrl = new DiametersComboBoxCtrl(); m_diametersComboBoxCtrl.CreateControl(); } } /// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // TODO: Add DiametersComboBoxToolCtrl.OnClick implementation } #endregion #region IToolControl Members public bool OnDrop(esriCmdBarType barType) { return true; } public void OnFocus(ICompletionNotify complete) { } public int hWnd { get { //pass the handle of the usercontrol if (null == m_diametersComboBoxCtrl) { m_diametersComboBoxCtrl = new DiametersComboBoxCtrl(); m_diametersComboBoxCtrl.CreateControl(); } return m_diametersComboBoxCtrl.Handle.ToInt32(); } } #endregion } }
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.