WebListBox - how to undo 'SetFocus'

Hello all,

I use the SetFocus command in certain instances. However, after that is done, I want to remove that set focus. How is that done?

Here’s my code. As you can see, at the end of the event I call SetFocus on the Container itself. But, in practice the field that had the set focus command still retains it.

Any ideas would be appreciated!
Thanks,
Tim

Sub Pressed(row As Integer, column As Integer) Handles Pressed
  
  Select Case Activecnt 
  Case "cntCreateUnit"
    Dim UID As String = Me.CellTextAt(row, 0)
    
    Session.ACP_Units.ChangeSID(SID.ToString)
    Dim Result As Integer = Session.ACP_Units.getUnitID(UID, True)
    Call cntCreateUnit.Clear
    
    cntCreateUnit.fldBldgNo.Text = Session.ACP_Units.BldgNo
    cntCreateUnit.fldDoorNo.Text = Session.ACP_Units.DoorNo
    cntCreateUnit.fldUnitID.Text = Session.ACP_Units.UnitID
    cntCreateUnit.fldUnitID.SetFocus
    
    cntCreateUnit.fldUnitName.Text = ""
    
    cntCreateUnit.chkLockedOut.Value = False
    If Session.ACP_Units.LockedOut = "Y" Then cntCreateUnit.chkLockedOut.Value = True
    
    cntCreateUnit.chkNRCUnit.Value = False
    If Session.ACP_Units.NRC = "Y" Then cntCreateUnit.chkNRCUnit.Value = True
    
    cntCreateUnit.chkOutOfService.Value = False
    If Session.ACP_Units.OutOfService = "Y" Then cntCreateUnit.chkOutOfService.Value = True
    
    
    cntCreateUnit.chkSAPUnit.Value = False
    If Session.ACP_Units.SAP = "Y" Then cntCreateUnit.chkSAPUnit.Value = True
    
    cntCreateUnit.chkWireless.Value = False
    
    cntCreateUnit.cmbAlarmZone.SelectRowWithText(Session.ACP_Units.AlarmZone.ToString )
    cntCreateUnit.cmbFloor.SelectRowWithText(Session.ACP_Units.Floor.ToString)
    cntCreateUnit.cmbKPZone.SelectRowWithText(Session.ACP_Units.KeypadZone.ToString)
    //cntCreateUnit.cmbUnitID_Len.SelectRowWithText(Session.ACP_Units.
    //cntCreateUnit.cmbWirelessZone.SelectRowWithText(Session.ACP_Units.
    
    //cntCreateUnit.fldBldgNo.Text = Session.ACP_Units.BldgNo
    //cntCreateUnit.fldDoorNo.Text = Session.ACP_Units.DoorNo
    //cntCreateUnit.fldUnitID.Text = Session.ACP_Units.UnitID
    //cntCreateUnit.fldUnitName.Text = ""
    cntCreateUnit.SetFocus
    Return
    
    
    
  Case "Assign Messages"
    
    
    
  End Select
  
  Return
  
  
  
  
  Exception e As RuntimeException
    Dim Logs As New clsLogging
    Dim Flds() As String = Array("EXCEPTION", CurrentMethodName, CStr( e.Type) )
    Logs.AddFields Flds
    Logs.LogFileAppend( Logs.K_Except_App_Err)
    
    
End Sub

perhaps you can manage the behavior with a boolean flag, day DoSetFocus. You would do something like this:

...
If DoSetFocus = True then
cntCreateUnit.SetFocus
DoSetFocus = False
End If 
...

Some other code would manage the flag such that it is true when it is appropriate to set the focus on the control. This is a simplistic example, but the concept may be applicable.

Hoping that this helps.

What is fldUnitID?

I can’t reproduce using a Container with a WebTextField in it and this code on a button outside the container:

Container11.TextField1.SetFocus
Container11.SetFocus

the focus does not stay with the textfield.

Can you share a sample?

Hi Alberto.

It is a container within a container, and the WebTextField object is in the nested container.
This is how it is, and it does set the focus but it appears to stay there (without any input). But once input is presented the focus does change. I was wanted to remove the focus ring around the field.

Container11.TextField1.SetFocus

In any case, not an urgency but thank you for your response!
Tim

If you can create a simple sample maybe there is something that can be reported.