Adding Spread at runtime to Panel placeholder, tab out of spread tabs to 1st control in tab order rather than next

Posted by: davewill-fp on 8 September 2017, 12:57 pm EST

  • Posted 8 September 2017, 12:57 pm EST

    VS.NET 2005
    Spread.NET 3.0.2005.2005

    I have a form that has a panel on it as a placeholder for a Spread to be added to it at runtime.  When tabbing from control to control when exiting the Spread it tabs to the 1st control in the tab order rather than the next control in the tab order.

    I have attached a test project where the tab order is Button1 ... Spread ... Button2.  When tabbing through it goes Button1 ... Spread ... Button1.

    As a test I added a Button to the container instead of the Spread to see what it would do.  It tabbed as expected ... Button1 ... Panel Button ... Button2.

    Is there a way I can get the tab sequence when using the Spread to be Button1 ... Spread ... Button2?

  • Replied 8 September 2017, 12:57 pm EST


    There looks to be a bug in the .NET Framework with the function SelectNextControl. This is the function we are using to set focus to the next control. I put that code in the ButtonClick event of a button I put in the Panel and it has the same issue,

      <SPAN class=kwd>Public Sub New</SPAN>()

    <SPAN class=cmt>' This call is required by the Windows Form Designer.

    <SPAN class=kwd>Dim</SPAN> b <SPAN class=kwd>As New</SPAN> Button
    <SPAN class=kwd>AddHandler</SPAN> b.Click, <SPAN class=kwd>AddressOf</SPAN> myClick

    <SPAN class=kwd>End Sub

    Private Sub</SPAN> myclick(<SPAN class=kwd>ByVal</SPAN> sender <SPAN class=kwd>As Object</SPAN>, <SPAN class=kwd>ByVal</SPAN> e <SPAN class=kwd>As</SPAN> System.EventArgs)
    <SPAN class=kwd>Me</SPAN>.SelectNextControl(sender, <SPAN class=kwd>True</SPAN>, <SPAN class=kwd>True</SPAN>, <SPAN class=kwd>False</SPAN>, <SPAN class=kwd>True</SPAN>)

    <SPAN class=kwd>End Sub</SPAN>
  • Replied 8 September 2017, 12:57 pm EST

    When I added the button to the panel it tabbed to the expected next control.

    NOTE: I did not put the selectnextcontrol call in the click ... I just added the button to the panel just as you did in the Sub New() routine.

    When I was debugging I did a GetNextControl in the Advance event to see what it was returning and it returned a Spread object named "a" (obfuscated name i presume).  I did a dump of the object to see what properties it exposed and it was not a Windows control and had Spread properties galor.
  • Replied 8 September 2017, 12:57 pm EST


    The Button must be doing other code to get this to work with their control. I do not see anything documented why this method does not work in certain cases, but I can reproduce it with the Button control (code I sent you).

  • Replied 8 September 2017, 12:57 pm EST

    Putting the following in the Spread Advance event seems to do the trick:

    e.Cancel = True
    Me.FindForm.SelectNextControl(Me, True, True, True, True)

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels