title: vb.net - how to change a property of a form element from another module
body: <p>I am trying to change the background color of a button (cmdLogQry) from a Set-procedure of a public property (LogQry) - according to the new value of the property.</p>
  
  <p>It works if the property is being changed in the code belongig to the form containing the button (in the Click method of the same or even another button). But it does not work if the property is being changed from another module (handler procedure for COM ports DataReceived event). No error message or anything - the LogQry gets its value changed all right, but the color of the button does not change.</p>
  
  <p>What do I do wrong?</p>
  
  <pre><code>Public Class Handler
  
  Private _logQry As Boolean = False
  
  Public Property LogQry() As Boolean
      Get
          Return _logQry
      End Get
      Set(ByVal value As Boolean)
          _logQry = value
          If value Then
              frmMain.cmdLogQry.BackColor = Color.Red
          Else
              frmMain.cmdLogQry.BackColor = Color.Blue
          End If
      End Set
  End Property
  
  Private Sub comPort_DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)
  ...
      LogQry = Not LogQry ' does NOT change color
  ...
  End Sub
  
  End Class
  
  Public Class frmMain     
  Private comm As New Handler()
  ...
  Private Sub cmdLogQry_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdLogQry.Click
      comm.LogQry = Not comm.LogQry ' does change color
  End Sub
  ...
  End Class
  </code></pre>