Asked by:
Textboxes in User Controls not updating in Windows 7 PRO

Question
-
I originally posted this in the Visual Basic Forum and it was suggested that I post it here as there does not seem to be an answer.
I have a usercontrol with a few textboxes and a progressbar.
The programme updates the textboxes and progressbar as it counts people coming through turnstiles.
It works fine under Windows XP and Windows 7 Ultimate and Windows Vista
However under Windows 7 Pro it does not.
It updates OK when the programme is counting. When the programme tries to clear the textboxes back to "0" it all goes wrong.
The progressbar goes to 0 but the textboxes remain unchanged. If I single step the programme it appears that the textbox.text value actualy changes to "0" but the textbox in the usercontrol still retains it's old value. If I the restart counting the usercontrol does not update. it appears that it has hung.
below is the code in the usercontrol. I tried the invoke method just to try it. it may not look pretty but it works(under XP)
There are 12 of these usercontrols on the form and they are on the form at design time and addressed via an array
dim MyStands(12) as usStand
mystands(1)=usStand1
mystands(2)=usStand2
etc....
To update the textboxes when the programme is counting:
for i = 1 to noofstands
mystands(i).setcount(InCount)
Next
To clear the textboxes:
for i as integer = 1 to noofstands ' could be less than 12
mystands(i).clearstandcounts
next
Public Class usStand
Public Property MyCapacity As Integer
Public Property MyStartCrowd As Integer
Public Property Myspace As Integer
Public Property MyAmber As Integer
Public Property MyRed As Integer
Public Property MyColour As Integer
Public Property InCount As Integer
Public Property MyName As String
Public Property MyID As Integer
Public Event AmberAlert(ByVal ID As Integer)
Public Event RedAlert(ByVal ID As Integer)
Public Event OverFlowAlert(ByVal ID As Integer)
Public UserSize As Long
' Private WithEvents tmrFlash As Timers.Timer
Private Property LastState As Integer = 0
Private Property AmberAlerted As Boolean
Private Property RedAlerted As Boolean
Private Property OverflowAlerted As BooleanPublic Sub SetColour(ByVal cn As Integer)
_MyColour = cn
With Me
.BackColor = Color.FromArgb(cn)
End WithEnd Sub
Public Sub SetName(ByVal Nm As String)
_MyName = Nm
Me.Label1.Text = _MyNameEnd Sub
Public Sub SetFlowRate(ByVal Value As Double)Me.txtFlowRate.Text = Value
End Sub
Public Sub SetTimeToFull(ByVal value As Double)
' Debug.Print("SetTimeToFull: " & MyName & " " & value)
Me.txtTimetoFull.Text = value
End Sub
Public Sub SetSpace()Dim sp As Integer = _MyCapacity - (_InCount + _MyStartCrowd)
txtSpace.Text = sp
End Sub
Private Sub CalcFlowRate()End Sub
Public Sub SetCount(ByVal crowd As Integer)
_InCount = crowdProgressBar1.Value = _InCount + _MyStartCrowd
'ProgressBar1.ResetText()
label5.Text = _InCount + _MyStartCrowd
SetSpace()
Dim ls As Integer = CheckAlarm()Select Case ls
Case Is = 0
Me.label5.BackColor = Color.LightGreen
Me.BackColor = Color.FromArgb(MyColour)
Case Is = 1
Me.label5.BackColor = Color.KhakiCase Is = 2
Me.label5.BackColor = Color.Orange
If Not AmberAlerted Then
RaiseEvent AmberAlert(MyID)
AmberAlerted = True
End If
Case Is = 3
Me.label5.BackColor = Color.Red
If Not RedAlerted Then
RaiseEvent RedAlert(MyID)
RedAlerted = True
End If
Case Is = 4
Me.BackColor = Color.Red
If Not OverflowAlerted Then
RaiseEvent OverFlowAlert(MyID)
OverflowAlerted = True
End IfEnd Select
End Sub
Public Sub SetCapacity(ByVal capacity As Integer)
_MyCapacity = capacity
Me.ProgressBar1.Maximum = capacity
End Sub
Public Sub SetStartCrowd(ByVal sc As Integer)
If sc > _MyCapacity Then
MsgBox("The value you entered for StartCrowd exceeds the capacity of the stand", MsgBoxStyle.OkOnly)
Exit Sub
End If
_MyStartCrowd = sc
ProgressBar1.Value = sc
SetSpace()
End Sub
Public Sub ClearStandCounts()
Try ' InCount = MyStartCrowd
_InCount = 0
Me.BackColor = Color.FromArgb(_MyColour)_Myspace = _MyCapacity - (_InCount + _MyStartCrowd)
Invoke(New SetTexts(AddressOf DoSetTexts))' SetSpace()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Function CheckAlarm() As Integer
Dim a, b, c, d As Boolean
a = _InCount > _MyCapacity * _MyAmber / 100
b = _InCount > _MyCapacity * _MyAmber / 100
c = _InCount > _MyCapacity * _MyRed / 100
d = _InCount > _MyCapacity
Dim ca As Integer = 0
If a Then ca = 1
If b Then ca = 2
If c Then ca = 3
If d Then ca = 4
'If InCount > MyCapacity * myAmber1Alert / 100 Then
' ca = 1
'ElseIf InCount > MyCapacity * myAmber2Alert / 100 Then
' ca = 2
'ElseIf InCount > MyCapacity * myRedAlert / 100 Then
' ca = 3
'ElseIf InCount > MyCapacity Then
' ca = 4
'End If
Return ca
End Function
Public Function GetData() As Integer
Dim i As Integer = 0Return i
End Function
Private Delegate Sub SetTexts()Private Sub DoSetTexts()
Me.txtFlowRate.Focus()
Me.txtFlowRate.Text = "0"
Me.txtSpace.Text = _Myspace
Me.txtTimeToFull.Text = "0"
Me.ProgressBar1.Value = _InCount + _MyStartCrowd
Me.label5.Text = _InCount + _MyStartCrowdMe.label5.BackColor = Color.LightGreen
End Sub
End ClassI loaded VS2010 on the PC and deleted and rebuilt the User Control from scratch,, it still failed.
I changed the textboxes to labels and the control now works.
Is this normal for Windows 7 PRO?
Jim BartlettMonday, August 22, 2011 9:04 AM
All replies
-
Technically all editions of Win7 has the same code base, only features are limited based on editions.
Have you tested it on multiple Win7 PRO boxes with same result?
This isnt really a developer forum, but hopefully someone with programming experience can review the code and help.
Sumesh P - Microsoft Online Community SupportThursday, August 25, 2011 6:33 AM -
No I have not.
I only have one PC with 7 PRO on. I do not have a spare PC I can load 7 PRO onto as they are all inuse with XP and programmes that I know will not work with Windows 7.
But I do know that it works fine on 7 Ultimate.
The Pc with 7 PRO on is an Acer 430G. Acer were not much help when I asked them if there was anything odd about their PC and Windows 7. All they said was contact Microsoft.
Jim BartlettThursday, August 25, 2011 9:26 AM -
You can try installing Win7 onto a virtual machine on your existing PC or try reinstalling if that is feasible. It may be an issue with that particular installed instance of win7.
Again all editions of Win7 has the same code base.
Sumesh P - Microsoft Online Community SupportWednesday, August 31, 2011 9:32 AM