how to get a checkbox or toggle button on a toolbar via .NET?

1492
2
04-05-2010 08:21 PM
AKitch
by
Occasional Contributor
Hi All

I�??ve been building a custom ArcMap add-in via .NET (C#) and come to a hurdle. I have an EditTask and a toolbar. Basically I want the type of editing functionality to be dependant on the state of a checkbox or toggle button on the toolbar. There isn't any ArcGIS control templates that seem to help.

I noticed in this thread that it might be possible to alter the properties of a command button to create a toggle but I haven�??t had any success in doing this.
http://forums.esri.com/Thread.asp?c=159&f=1707&t=224055

I�??ve also downloaded some for Neil Clemmons�?? code from this thread http://forums.esri.com/Thread.asp?c=93&f=1170&t=300794&mc=2 but I�??m still not sure how it�??s done. Do I have to develop my own ArcGIS registered control and add it to my toolbar? I haven�??t had experience in doing this so pointers to tutorials would be handy.

Ultimately if anyone has a suggestion on how best to solve the problem I�??d be very grateful.

Cheers

Adrian
0 Kudos
2 Replies
KirkKuykendall
Occasional Contributor III
I would write an editor extension and have both the toolcontrol (with the checkbox) and the edittask talk to the edit extension to decide how to behave.  The extension would not be aware, however, of the toolcontrol or the edittask - if it needs to be notified then use events. 

For example, if the edittask needs to  know that the checkbox has been checked/unchecked while it is the current task, it would subscribe to a checkchanged event which would be raised by the edit extension whenever the Enabled state is changed (possibly - but not necessarily - by the checkbox on the toolcontrol).

Wiring all these notifications can be a bit daunting.  Silverlight/WPF provides a much cleaner way of doing this (through XAML and INotifyPropertyChanged) , but haven't looked into using it with editing events.  I suppose there would need to be a WPF based toolbar?  Anyway, I would be interested in seeing an example using WPF to write controls that support this scenario.
0 Kudos
AKitch
by
Occasional Contributor
Thanks for the suggestion Kirk

I had a look into Editor Extension and noticed there was a good example in the .NET samples called �??ValidateFeatures�??, or in the Developer help called �??Validate Features extension�??. The main problem with this was that the edit �??type�?? was toggled through Editor Options. I was hoping to have something that could be accessed quickly while digitising hence the use of a toolbar.

Anyway I seem to have worked out a clunky work around. Basically I change the caption on a command button when it pressed. During the edit session after a sketch is finished I access the command button on the toolbar using the ArcGIS snippet called "Get Command on Toolbar by Names". Once I have access to the command I then see what the caption is and alter my editing functions as needed. I had to make one alteration in the snippet which was defining the commandID.SubType to that which the command was set to when added to the tool bar. Not the prettiest way of doing it I�??m sure but gets the job done.

Cheers

Adrian
0 Kudos