<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Addin combobox not releasing focus in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/addin-combobox-not-releasing-focus/m-p/314960#M8224</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: kjweaver&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I consider this a "hack", but here's how I solved the problem to make the addin combobox behave the way I wanted.&amp;nbsp; With this, the Windows Form opens and has focus and the combobox closes, clears, and loses focus.&amp;nbsp; Also the combobox contents are only computed once (my combobox contains many conditional items from SQL table queries so it is not practical to requery for the contents every time the combobox gets focus, etc.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 Public g_sComboValue as String = ""&amp;nbsp; ' global public variable used to pass selection to Windows form frmMyWinForm

 Public Class MyCombo_Tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; Inherits ESRI.ArcGIS.Desktop.AddIns.ComboBox

 Private Shared aLayers As New List(Of String)

 Public Sub New()
&amp;nbsp;&amp;nbsp;&amp;nbsp; GetComboData()&amp;nbsp;&amp;nbsp;&amp;nbsp; ' private sub that fills aLayers() with the contents to put in the combo, but does not fill the combobox. 
' Code for this sub is not included in this example, but basically can be as simple as aLayers.Add("Item1") . . . 
 End Sub

 Protected Overrides Sub OnSelChange(ByVal cookie As Integer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Exit if no item chosen from combobox
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If cookie = -1 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Sub
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g_sComboValue = myComboBox.Value&amp;nbsp; ' grab the selection to pass to the next form
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call FillCombo()&amp;nbsp;&amp;nbsp; ' FillCombo clears and refills the combo to clear the previous selection displayed in the editbox
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
 End Sub


 Protected Overrides Sub OnUpdate()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enabled = My.ArcMap.Application IsNot Nothing

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If g_sComboValue &amp;lt;&amp;gt; "" Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myComboBox.Finalize()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
 End Sub


 Protected Overrides Sub Finalize()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; frmMyWinForm= New frmMyWinForm
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; frmMyWinForm.ShowDialog()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g_sComboValue = ""
 End Sub


 Private Sub FillCombo()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' fill combobox from array list
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim n As Integer = aLayers.Count
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim i As Integer = 0

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myComboBox.Clear()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 0 To n - 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myComboBox.Add(aLayers(i))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next i

 End Sub
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:59:53 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-11T14:59:53Z</dc:date>
    <item>
      <title>Addin combobox not releasing focus</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/addin-combobox-not-releasing-focus/m-p/314959#M8223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: kjweaver&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In ArcMap 10, I have an addin combobox on a tool bar. Once the user selects an option from the combobox, a Windows form opens to enable them to enter some information based on their selection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, the focus does not shift to the Windows form but stays on the combobox.&amp;nbsp; I've tried using both .Show() and .ShowDialog() to display the form.&amp;nbsp; .Show() allows the combobox drop-down to close but the focus remains on the combobox control.&amp;nbsp; I've also tried forcing the focus to the Windows form in the tool's OnSelChange event and in the form's Load/Activate/Shown events.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My question is: how do I signal to the addin combobox control that it should complete and release focus?&amp;nbsp; If this were a traditional ITool combobox, I would use the esriSystemUI.ICompletionNotify technique to send a completed message.&amp;nbsp; The addin combobox seems to have very few Methods/Events available.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do I release the tool so I can reset the focus to the Windows form (or anywhere else)?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Sep 2012 17:05:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/addin-combobox-not-releasing-focus/m-p/314959#M8223</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-09-04T17:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Addin combobox not releasing focus</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/addin-combobox-not-releasing-focus/m-p/314960#M8224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: kjweaver&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I consider this a "hack", but here's how I solved the problem to make the addin combobox behave the way I wanted.&amp;nbsp; With this, the Windows Form opens and has focus and the combobox closes, clears, and loses focus.&amp;nbsp; Also the combobox contents are only computed once (my combobox contains many conditional items from SQL table queries so it is not practical to requery for the contents every time the combobox gets focus, etc.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 Public g_sComboValue as String = ""&amp;nbsp; ' global public variable used to pass selection to Windows form frmMyWinForm

 Public Class MyCombo_Tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; Inherits ESRI.ArcGIS.Desktop.AddIns.ComboBox

 Private Shared aLayers As New List(Of String)

 Public Sub New()
&amp;nbsp;&amp;nbsp;&amp;nbsp; GetComboData()&amp;nbsp;&amp;nbsp;&amp;nbsp; ' private sub that fills aLayers() with the contents to put in the combo, but does not fill the combobox. 
' Code for this sub is not included in this example, but basically can be as simple as aLayers.Add("Item1") . . . 
 End Sub

 Protected Overrides Sub OnSelChange(ByVal cookie As Integer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Exit if no item chosen from combobox
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If cookie = -1 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Sub
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g_sComboValue = myComboBox.Value&amp;nbsp; ' grab the selection to pass to the next form
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call FillCombo()&amp;nbsp;&amp;nbsp; ' FillCombo clears and refills the combo to clear the previous selection displayed in the editbox
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
 End Sub


 Protected Overrides Sub OnUpdate()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enabled = My.ArcMap.Application IsNot Nothing

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If g_sComboValue &amp;lt;&amp;gt; "" Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myComboBox.Finalize()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
 End Sub


 Protected Overrides Sub Finalize()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; frmMyWinForm= New frmMyWinForm
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; frmMyWinForm.ShowDialog()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g_sComboValue = ""
 End Sub


 Private Sub FillCombo()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' fill combobox from array list
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim n As Integer = aLayers.Count
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim i As Integer = 0

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myComboBox.Clear()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 0 To n - 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myComboBox.Add(aLayers(i))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next i

 End Sub
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:59:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/addin-combobox-not-releasing-focus/m-p/314960#M8224</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T14:59:53Z</dc:date>
    </item>
  </channel>
</rss>

