PC Review


Reply
Thread Tools Rate Thread

Label Weirdness

 
 
Harry Simpson
Guest
Posts: n/a
 
      15th Mar 2005
I am trying to display/hide a label either by visible or manipilating the
Left property.

Why would a label not appear at runtime on a panel. I've right clicked and
done the Bring to Front deal.

I even used a label that I am able to change the text in. When I add code
to change the text, it won't work for the original function either. What's
going on! I've been trying to solve this all afternoon..

TIA
Harry


 
Reply With Quote
 
 
 
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      15th Mar 2005
Post some code.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


"Harry Simpson" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I am trying to display/hide a label either by visible or manipilating the
>Left property.
>
> Why would a label not appear at runtime on a panel. I've right clicked
> and done the Bring to Front deal.
>
> I even used a label that I am able to change the text in. When I add code
> to change the text, it won't work for the original function either.
> What's going on! I've been trying to solve this all afternoon..
>
> TIA
> Harry
>
>



 
Reply With Quote
 
Harry Simpson
Guest
Posts: n/a
 
      16th Mar 2005
Chris,

Maybe the problem is that I'm trying to set the property twice within one
proc in the tick event???

Here's the code:
This timer fires every five minutes. IT makes about a thirty second trip to
the server to grab fresh data....I want to alert the user in a more
pronouced way that they need to leave the device cradled until after the
sync.....

Private Sub tmrRefreshData_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles tmrRefreshData.Tick
Dim objLocalDB As New LocalDB
Dim ds As New DataSet
Dim blnUsersRetrieved As Boolean

lblWait.Text = "WAIT"
Try
CheckConnection()
Catch ex As Exception
'MsgBox("Unable to verify connection")

End Try


If g_blnConnected = True And g_blnLocalDBExists = True Then
Try
ds = objLocalDB.GetUsers
If ds.Tables(0).Rows.Count > 0 Then
blnUsersRetrieved = True
g_dsUsers = ds
End If

If g_blnLocalDBExists And blnUsersRetrieved Then
Try
RefreshLocalDatabase()
Catch ex As SqlServerCe.SqlCeException
MsgBox(ex.Message.ToString)
Finally

End Try
End If
Catch ex As Exception

End Try

End If



lblWait.Text = " "

Dim TimeNow As DateTime = DateTime.Now
Dim MyString As String = TimeNow.ToString("hh:mm")

lblLastSync.Text = "Last Sync : " & MyString.TrimStart("0")
End Sub

"Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Post some code.
>
> --
> Chris Tacke
> Co-founder
> OpenNETCF.org
> Has OpenNETCF helped you? Consider donating to support us!
> http://www.opennetcf.org/donate
>
>
> "Harry Simpson" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>I am trying to display/hide a label either by visible or manipilating the
>>Left property.
>>
>> Why would a label not appear at runtime on a panel. I've right clicked
>> and done the Bring to Front deal.
>>
>> I even used a label that I am able to change the text in. When I add
>> code to change the text, it won't work for the original function either.
>> What's going on! I've been trying to solve this all afternoon..
>>
>> TIA
>> Harry
>>
>>

>
>



 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      16th Mar 2005
Typically when the timer fires (tick handler) you disable it and at the end
of the sub you re-enable it...

Regardless, try an Application.DoEvents after lblWait.Text = "WAIT"

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Harry Simpson" <(E-Mail Removed)> wrote in message
news:%23jov%(E-Mail Removed)...
> Chris,
>
> Maybe the problem is that I'm trying to set the property twice within one
> proc in the tick event???
>
> Here's the code:
> This timer fires every five minutes. IT makes about a thirty second trip
> to the server to grab fresh data....I want to alert the user in a more
> pronouced way that they need to leave the device cradled until after the
> sync.....
>
> Private Sub tmrRefreshData_Tick(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles tmrRefreshData.Tick
> Dim objLocalDB As New LocalDB
> Dim ds As New DataSet
> Dim blnUsersRetrieved As Boolean
>
> lblWait.Text = "WAIT"
> Try
> CheckConnection()
> Catch ex As Exception
> 'MsgBox("Unable to verify connection")
>
> End Try
>
>
> If g_blnConnected = True And g_blnLocalDBExists = True Then
> Try
> ds = objLocalDB.GetUsers
> If ds.Tables(0).Rows.Count > 0 Then
> blnUsersRetrieved = True
> g_dsUsers = ds
> End If
>
> If g_blnLocalDBExists And blnUsersRetrieved Then
> Try
> RefreshLocalDatabase()
> Catch ex As SqlServerCe.SqlCeException
> MsgBox(ex.Message.ToString)
> Finally
>
> End Try
> End If
> Catch ex As Exception
>
> End Try
>
> End If
>
>
>
> lblWait.Text = " "
>
> Dim TimeNow As DateTime = DateTime.Now
> Dim MyString As String = TimeNow.ToString("hh:mm")
>
> lblLastSync.Text = "Last Sync : " & MyString.TrimStart("0")
> End Sub
>
> "Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Post some code.
>>
>> --
>> Chris Tacke
>> Co-founder
>> OpenNETCF.org
>> Has OpenNETCF helped you? Consider donating to support us!
>> http://www.opennetcf.org/donate
>>
>>
>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>>I am trying to display/hide a label either by visible or manipilating the
>>>Left property.
>>>
>>> Why would a label not appear at runtime on a panel. I've right clicked
>>> and done the Bring to Front deal.
>>>
>>> I even used a label that I am able to change the text in. When I add
>>> code to change the text, it won't work for the original function either.
>>> What's going on! I've been trying to solve this all afternoon..
>>>
>>> TIA
>>> Harry
>>>
>>>

>>
>>

>
>


 
Reply With Quote
 
Harry Simpson
Guest
Posts: n/a
 
      16th Mar 2005
Daniel,

You da man!!

After I posted this last night, i thought Harry you need a vacation. You
can't set the label text twice within one proc event!! So this morning I had
it call subs from the same points within the proc and it still wouldn't
work. Added the Application.DoEvents to the seperate procs and it's
working. Is this a CF bug?

Appreciate your insight....haven't used DoEvents since VB3!!

Thanks
Harry

"Daniel Moth" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Typically when the timer fires (tick handler) you disable it and at the
> end of the sub you re-enable it...
>
> Regardless, try an Application.DoEvents after lblWait.Text = "WAIT"
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> "Harry Simpson" <(E-Mail Removed)> wrote in message
> news:%23jov%(E-Mail Removed)...
>> Chris,
>>
>> Maybe the problem is that I'm trying to set the property twice within one
>> proc in the tick event???
>>
>> Here's the code:
>> This timer fires every five minutes. IT makes about a thirty second trip
>> to the server to grab fresh data....I want to alert the user in a more
>> pronouced way that they need to leave the device cradled until after the
>> sync.....
>>
>> Private Sub tmrRefreshData_Tick(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles tmrRefreshData.Tick
>> Dim objLocalDB As New LocalDB
>> Dim ds As New DataSet
>> Dim blnUsersRetrieved As Boolean
>>
>> lblWait.Text = "WAIT"
>> Try
>> CheckConnection()
>> Catch ex As Exception
>> 'MsgBox("Unable to verify connection")
>>
>> End Try
>>
>>
>> If g_blnConnected = True And g_blnLocalDBExists = True Then
>> Try
>> ds = objLocalDB.GetUsers
>> If ds.Tables(0).Rows.Count > 0 Then
>> blnUsersRetrieved = True
>> g_dsUsers = ds
>> End If
>>
>> If g_blnLocalDBExists And blnUsersRetrieved Then
>> Try
>> RefreshLocalDatabase()
>> Catch ex As SqlServerCe.SqlCeException
>> MsgBox(ex.Message.ToString)
>> Finally
>>
>> End Try
>> End If
>> Catch ex As Exception
>>
>> End Try
>>
>> End If
>>
>>
>>
>> lblWait.Text = " "
>>
>> Dim TimeNow As DateTime = DateTime.Now
>> Dim MyString As String = TimeNow.ToString("hh:mm")
>>
>> lblLastSync.Text = "Last Sync : " & MyString.TrimStart("0")
>> End Sub
>>
>> "Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Post some code.
>>>
>>> --
>>> Chris Tacke
>>> Co-founder
>>> OpenNETCF.org
>>> Has OpenNETCF helped you? Consider donating to support us!
>>> http://www.opennetcf.org/donate
>>>
>>>
>>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>>I am trying to display/hide a label either by visible or manipilating
>>>>the
>>>>Left property.
>>>>
>>>> Why would a label not appear at runtime on a panel. I've right clicked
>>>> and done the Bring to Front deal.
>>>>
>>>> I even used a label that I am able to change the text in. When I add
>>>> code to change the text, it won't work for the original function
>>>> either.
>>>> What's going on! I've been trying to solve this all afternoon..
>>>>
>>>> TIA
>>>> Harry
>>>>
>>>>
>>>
>>>

>>
>>

>



 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      16th Mar 2005
It is not a CF bug. I haven't use DoEvents since VB classic (and still never
had to use it in my .NET apps).

The easiest way to think of it is that methods running on the UI thread
(e.g. button1_Click, timer1_Tick etc) must be very short (in terms of
execution time) and anything we change in there takes effect after the
method has run (at the point of End Sub). To that end if you need a process
to run for a long time you use a thread (or BackgroundWorker or some other
wrapper) from the UI method.

If you choose to violate that design and run some long processing from a UI
method (e.g. like you do in the timer tick), then any UI changes (e.g.
lblWait.Text=) will not have an effect until the method exits. For the
changes to have an effect you must notify the windows message pump to
process any pending messages and that is exactly what DoEvents does.

Anyway, glad it's working for you.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Harry Simpson" <(E-Mail Removed)> wrote in message
news:uwm%(E-Mail Removed)...
> Daniel,
>
> You da man!!
>
> After I posted this last night, i thought Harry you need a vacation. You
> can't set the label text twice within one proc event!! So this morning I
> had it call subs from the same points within the proc and it still
> wouldn't work. Added the Application.DoEvents to the seperate procs and
> it's working. Is this a CF bug?
>
> Appreciate your insight....haven't used DoEvents since VB3!!
>
> Thanks
> Harry
>
> "Daniel Moth" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Typically when the timer fires (tick handler) you disable it and at the
>> end of the sub you re-enable it...
>>
>> Regardless, try an Application.DoEvents after lblWait.Text = "WAIT"
>>
>> Cheers
>> Daniel
>> --
>> http://www.danielmoth.com/Blog/
>>
>>
>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>> news:%23jov%(E-Mail Removed)...
>>> Chris,
>>>
>>> Maybe the problem is that I'm trying to set the property twice within
>>> one
>>> proc in the tick event???
>>>
>>> Here's the code:
>>> This timer fires every five minutes. IT makes about a thirty second
>>> trip
>>> to the server to grab fresh data....I want to alert the user in a more
>>> pronouced way that they need to leave the device cradled until after the
>>> sync.....
>>>
>>> Private Sub tmrRefreshData_Tick(ByVal sender As System.Object, ByVal e
>>> As
>>> System.EventArgs) Handles tmrRefreshData.Tick
>>> Dim objLocalDB As New LocalDB
>>> Dim ds As New DataSet
>>> Dim blnUsersRetrieved As Boolean
>>>
>>> lblWait.Text = "WAIT"
>>> Try
>>> CheckConnection()
>>> Catch ex As Exception
>>> 'MsgBox("Unable to verify connection")
>>>
>>> End Try
>>>
>>>
>>> If g_blnConnected = True And g_blnLocalDBExists = True Then
>>> Try
>>> ds = objLocalDB.GetUsers
>>> If ds.Tables(0).Rows.Count > 0 Then
>>> blnUsersRetrieved = True
>>> g_dsUsers = ds
>>> End If
>>>
>>> If g_blnLocalDBExists And blnUsersRetrieved Then
>>> Try
>>> RefreshLocalDatabase()
>>> Catch ex As SqlServerCe.SqlCeException
>>> MsgBox(ex.Message.ToString)
>>> Finally
>>>
>>> End Try
>>> End If
>>> Catch ex As Exception
>>>
>>> End Try
>>>
>>> End If
>>>
>>>
>>>
>>> lblWait.Text = " "
>>>
>>> Dim TimeNow As DateTime = DateTime.Now
>>> Dim MyString As String = TimeNow.ToString("hh:mm")
>>>
>>> lblLastSync.Text = "Last Sync : " & MyString.TrimStart("0")
>>> End Sub
>>>
>>> "Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>> Post some code.
>>>>
>>>> --
>>>> Chris Tacke
>>>> Co-founder
>>>> OpenNETCF.org
>>>> Has OpenNETCF helped you? Consider donating to support us!
>>>> http://www.opennetcf.org/donate
>>>>
>>>>
>>>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>>>> news:%(E-Mail Removed)...
>>>>>I am trying to display/hide a label either by visible or manipilating
>>>>>the
>>>>>Left property.
>>>>>
>>>>> Why would a label not appear at runtime on a panel. I've right
>>>>> clicked
>>>>> and done the Bring to Front deal.
>>>>>
>>>>> I even used a label that I am able to change the text in. When I add
>>>>> code to change the text, it won't work for the original function
>>>>> either.
>>>>> What's going on! I've been trying to solve this all afternoon..
>>>>>
>>>>> TIA
>>>>> Harry
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>

>
>


 
Reply With Quote
 
Harry Simpson
Guest
Posts: n/a
 
      16th Mar 2005
Thanks Daniel,

<<To that end if you need a process
to run for a long time you use a thread (or BackgroundWorker or some other
wrapper) from the UI method.

If you choose to violate that design and run some long processing from a UI
method (e.g. like you do in the timer tick), then any UI changes (e.g.
lblWait.Text=) will not have an effect until the method exits. >>

Could you point me to a place where I could get more information about this.
I don't want to violate best practices but plead ignorance and would like to
learn.

So you mean start a thread instead of enableing a timer?

TIA
Harry


"Daniel Moth" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> It is not a CF bug. I haven't use DoEvents since VB classic (and still
> never had to use it in my .NET apps).
>
> The easiest way to think of it is that methods running on the UI thread
> (e.g. button1_Click, timer1_Tick etc) must be very short (in terms of
> execution time) and anything we change in there takes effect after the
> method has run (at the point of End Sub). To that end if you need a
> process to run for a long time you use a thread (or BackgroundWorker or
> some other wrapper) from the UI method.
>
> If you choose to violate that design and run some long processing from a
> UI method (e.g. like you do in the timer tick), then any UI changes (e.g.
> lblWait.Text=) will not have an effect until the method exits. For the
> changes to have an effect you must notify the windows message pump to
> process any pending messages and that is exactly what DoEvents does.
>
> Anyway, glad it's working for you.
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> "Harry Simpson" <(E-Mail Removed)> wrote in message
> news:uwm%(E-Mail Removed)...
>> Daniel,
>>
>> You da man!!
>>
>> After I posted this last night, i thought Harry you need a vacation. You
>> can't set the label text twice within one proc event!! So this morning I
>> had it call subs from the same points within the proc and it still
>> wouldn't work. Added the Application.DoEvents to the seperate procs and
>> it's working. Is this a CF bug?
>>
>> Appreciate your insight....haven't used DoEvents since VB3!!
>>
>> Thanks
>> Harry
>>
>> "Daniel Moth" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Typically when the timer fires (tick handler) you disable it and at the
>>> end of the sub you re-enable it...
>>>
>>> Regardless, try an Application.DoEvents after lblWait.Text = "WAIT"
>>>
>>> Cheers
>>> Daniel
>>> --
>>> http://www.danielmoth.com/Blog/
>>>
>>>
>>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>>> news:%23jov%(E-Mail Removed)...
>>>> Chris,
>>>>
>>>> Maybe the problem is that I'm trying to set the property twice within
>>>> one
>>>> proc in the tick event???
>>>>
>>>> Here's the code:
>>>> This timer fires every five minutes. IT makes about a thirty second
>>>> trip
>>>> to the server to grab fresh data....I want to alert the user in a more
>>>> pronouced way that they need to leave the device cradled until after
>>>> the
>>>> sync.....
>>>>
>>>> Private Sub tmrRefreshData_Tick(ByVal sender As System.Object, ByVal e
>>>> As
>>>> System.EventArgs) Handles tmrRefreshData.Tick
>>>> Dim objLocalDB As New LocalDB
>>>> Dim ds As New DataSet
>>>> Dim blnUsersRetrieved As Boolean
>>>>
>>>> lblWait.Text = "WAIT"
>>>> Try
>>>> CheckConnection()
>>>> Catch ex As Exception
>>>> 'MsgBox("Unable to verify connection")
>>>>
>>>> End Try
>>>>
>>>>
>>>> If g_blnConnected = True And g_blnLocalDBExists = True Then
>>>> Try
>>>> ds = objLocalDB.GetUsers
>>>> If ds.Tables(0).Rows.Count > 0 Then
>>>> blnUsersRetrieved = True
>>>> g_dsUsers = ds
>>>> End If
>>>>
>>>> If g_blnLocalDBExists And blnUsersRetrieved Then
>>>> Try
>>>> RefreshLocalDatabase()
>>>> Catch ex As SqlServerCe.SqlCeException
>>>> MsgBox(ex.Message.ToString)
>>>> Finally
>>>>
>>>> End Try
>>>> End If
>>>> Catch ex As Exception
>>>>
>>>> End Try
>>>>
>>>> End If
>>>>
>>>>
>>>>
>>>> lblWait.Text = " "
>>>>
>>>> Dim TimeNow As DateTime = DateTime.Now
>>>> Dim MyString As String = TimeNow.ToString("hh:mm")
>>>>
>>>> lblLastSync.Text = "Last Sync : " & MyString.TrimStart("0")
>>>> End Sub
>>>>
>>>> "Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message
>>>> news:%(E-Mail Removed)...
>>>>> Post some code.
>>>>>
>>>>> --
>>>>> Chris Tacke
>>>>> Co-founder
>>>>> OpenNETCF.org
>>>>> Has OpenNETCF helped you? Consider donating to support us!
>>>>> http://www.opennetcf.org/donate
>>>>>
>>>>>
>>>>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>>>>> news:%(E-Mail Removed)...
>>>>>>I am trying to display/hide a label either by visible or manipilating
>>>>>>the
>>>>>>Left property.
>>>>>>
>>>>>> Why would a label not appear at runtime on a panel. I've right
>>>>>> clicked
>>>>>> and done the Bring to Front deal.
>>>>>>
>>>>>> I even used a label that I am able to change the text in. When I add
>>>>>> code to change the text, it won't work for the original function
>>>>>> either.
>>>>>> What's going on! I've been trying to solve this all afternoon..
>>>>>>
>>>>>> TIA
>>>>>> Harry
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>

>>
>>

>



 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      16th Mar 2005
Since you've got something that works (and I can think of many worst
violations than using DoEvents, which can be unavoidable) I wouldn't worry
about it.

If you want to learn about BackgroundWorker have a look at this example (the
whole point is not to block your UI with long running tasks):
http://www.danielmoth.com/Blog/2004/...er-sample.html

Once you understand it, only you will know if it applies to your scenario.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Harry Simpson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Daniel,
>
> <<To that end if you need a process
> to run for a long time you use a thread (or BackgroundWorker or some other
> wrapper) from the UI method.
>
> If you choose to violate that design and run some long processing from a
> UI
> method (e.g. like you do in the timer tick), then any UI changes (e.g.
> lblWait.Text=) will not have an effect until the method exits. >>
>
> Could you point me to a place where I could get more information about
> this. I don't want to violate best practices but plead ignorance and would
> like to learn.
>
> So you mean start a thread instead of enableing a timer?
>
> TIA
> Harry
>
>
> "Daniel Moth" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> It is not a CF bug. I haven't use DoEvents since VB classic (and still
>> never had to use it in my .NET apps).
>>
>> The easiest way to think of it is that methods running on the UI thread
>> (e.g. button1_Click, timer1_Tick etc) must be very short (in terms of
>> execution time) and anything we change in there takes effect after the
>> method has run (at the point of End Sub). To that end if you need a
>> process to run for a long time you use a thread (or BackgroundWorker or
>> some other wrapper) from the UI method.
>>
>> If you choose to violate that design and run some long processing from a
>> UI method (e.g. like you do in the timer tick), then any UI changes (e.g.
>> lblWait.Text=) will not have an effect until the method exits. For the
>> changes to have an effect you must notify the windows message pump to
>> process any pending messages and that is exactly what DoEvents does.
>>
>> Anyway, glad it's working for you.
>>
>> Cheers
>> Daniel
>> --
>> http://www.danielmoth.com/Blog/
>>
>>
>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>> news:uwm%(E-Mail Removed)...
>>> Daniel,
>>>
>>> You da man!!
>>>
>>> After I posted this last night, i thought Harry you need a vacation.
>>> You can't set the label text twice within one proc event!! So this
>>> morning I had it call subs from the same points within the proc and it
>>> still wouldn't work. Added the Application.DoEvents to the seperate
>>> procs and it's working. Is this a CF bug?
>>>
>>> Appreciate your insight....haven't used DoEvents since VB3!!
>>>
>>> Thanks
>>> Harry
>>>
>>> "Daniel Moth" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> Typically when the timer fires (tick handler) you disable it and at the
>>>> end of the sub you re-enable it...
>>>>
>>>> Regardless, try an Application.DoEvents after lblWait.Text = "WAIT"
>>>>
>>>> Cheers
>>>> Daniel
>>>> --
>>>> http://www.danielmoth.com/Blog/
>>>>
>>>>
>>>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>>>> news:%23jov%(E-Mail Removed)...
>>>>> Chris,
>>>>>
>>>>> Maybe the problem is that I'm trying to set the property twice within
>>>>> one
>>>>> proc in the tick event???
>>>>>
>>>>> Here's the code:
>>>>> This timer fires every five minutes. IT makes about a thirty second
>>>>> trip
>>>>> to the server to grab fresh data....I want to alert the user in a more
>>>>> pronouced way that they need to leave the device cradled until after
>>>>> the
>>>>> sync.....
>>>>>
>>>>> Private Sub tmrRefreshData_Tick(ByVal sender As System.Object, ByVal e
>>>>> As
>>>>> System.EventArgs) Handles tmrRefreshData.Tick
>>>>> Dim objLocalDB As New LocalDB
>>>>> Dim ds As New DataSet
>>>>> Dim blnUsersRetrieved As Boolean
>>>>>
>>>>> lblWait.Text = "WAIT"
>>>>> Try
>>>>> CheckConnection()
>>>>> Catch ex As Exception
>>>>> 'MsgBox("Unable to verify connection")
>>>>>
>>>>> End Try
>>>>>
>>>>>
>>>>> If g_blnConnected = True And g_blnLocalDBExists = True Then
>>>>> Try
>>>>> ds = objLocalDB.GetUsers
>>>>> If ds.Tables(0).Rows.Count > 0 Then
>>>>> blnUsersRetrieved = True
>>>>> g_dsUsers = ds
>>>>> End If
>>>>>
>>>>> If g_blnLocalDBExists And blnUsersRetrieved Then
>>>>> Try
>>>>> RefreshLocalDatabase()
>>>>> Catch ex As SqlServerCe.SqlCeException
>>>>> MsgBox(ex.Message.ToString)
>>>>> Finally
>>>>>
>>>>> End Try
>>>>> End If
>>>>> Catch ex As Exception
>>>>>
>>>>> End Try
>>>>>
>>>>> End If
>>>>>
>>>>>
>>>>>
>>>>> lblWait.Text = " "
>>>>>
>>>>> Dim TimeNow As DateTime = DateTime.Now
>>>>> Dim MyString As String = TimeNow.ToString("hh:mm")
>>>>>
>>>>> lblLastSync.Text = "Last Sync : " & MyString.TrimStart("0")
>>>>> End Sub
>>>>>
>>>>> "Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message
>>>>> news:%(E-Mail Removed)...
>>>>>> Post some code.
>>>>>>
>>>>>> --
>>>>>> Chris Tacke
>>>>>> Co-founder
>>>>>> OpenNETCF.org
>>>>>> Has OpenNETCF helped you? Consider donating to support us!
>>>>>> http://www.opennetcf.org/donate
>>>>>>
>>>>>>
>>>>>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>>>>>> news:%(E-Mail Removed)...
>>>>>>>I am trying to display/hide a label either by visible or manipilating
>>>>>>>the
>>>>>>>Left property.
>>>>>>>
>>>>>>> Why would a label not appear at runtime on a panel. I've right
>>>>>>> clicked
>>>>>>> and done the Bring to Front deal.
>>>>>>>
>>>>>>> I even used a label that I am able to change the text in. When I
>>>>>>> add
>>>>>>> code to change the text, it won't work for the original function
>>>>>>> either.
>>>>>>> What's going on! I've been trying to solve this all afternoon..
>>>>>>>
>>>>>>> TIA
>>>>>>> Harry
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>

>>

>
>


 
Reply With Quote
 
Harry Simpson
Guest
Posts: n/a
 
      16th Mar 2005
Thanks Daniel,

I'll look over it - appreciate the help.

Harry

"Daniel Moth" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Since you've got something that works (and I can think of many worst
> violations than using DoEvents, which can be unavoidable) I wouldn't worry
> about it.
>
> If you want to learn about BackgroundWorker have a look at this example
> (the whole point is not to block your UI with long running tasks):
> http://www.danielmoth.com/Blog/2004/...er-sample.html
>
> Once you understand it, only you will know if it applies to your scenario.
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> "Harry Simpson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Thanks Daniel,
>>
>> <<To that end if you need a process
>> to run for a long time you use a thread (or BackgroundWorker or some
>> other
>> wrapper) from the UI method.
>>
>> If you choose to violate that design and run some long processing from a
>> UI
>> method (e.g. like you do in the timer tick), then any UI changes (e.g.
>> lblWait.Text=) will not have an effect until the method exits. >>
>>
>> Could you point me to a place where I could get more information about
>> this. I don't want to violate best practices but plead ignorance and
>> would like to learn.
>>
>> So you mean start a thread instead of enableing a timer?
>>
>> TIA
>> Harry
>>
>>
>> "Daniel Moth" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> It is not a CF bug. I haven't use DoEvents since VB classic (and still
>>> never had to use it in my .NET apps).
>>>
>>> The easiest way to think of it is that methods running on the UI thread
>>> (e.g. button1_Click, timer1_Tick etc) must be very short (in terms of
>>> execution time) and anything we change in there takes effect after the
>>> method has run (at the point of End Sub). To that end if you need a
>>> process to run for a long time you use a thread (or BackgroundWorker or
>>> some other wrapper) from the UI method.
>>>
>>> If you choose to violate that design and run some long processing from a
>>> UI method (e.g. like you do in the timer tick), then any UI changes
>>> (e.g. lblWait.Text=) will not have an effect until the method exits. For
>>> the changes to have an effect you must notify the windows message pump
>>> to process any pending messages and that is exactly what DoEvents does.
>>>
>>> Anyway, glad it's working for you.
>>>
>>> Cheers
>>> Daniel
>>> --
>>> http://www.danielmoth.com/Blog/
>>>
>>>
>>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>>> news:uwm%(E-Mail Removed)...
>>>> Daniel,
>>>>
>>>> You da man!!
>>>>
>>>> After I posted this last night, i thought Harry you need a vacation.
>>>> You can't set the label text twice within one proc event!! So this
>>>> morning I had it call subs from the same points within the proc and it
>>>> still wouldn't work. Added the Application.DoEvents to the seperate
>>>> procs and it's working. Is this a CF bug?
>>>>
>>>> Appreciate your insight....haven't used DoEvents since VB3!!
>>>>
>>>> Thanks
>>>> Harry
>>>>
>>>> "Daniel Moth" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> Typically when the timer fires (tick handler) you disable it and at
>>>>> the end of the sub you re-enable it...
>>>>>
>>>>> Regardless, try an Application.DoEvents after lblWait.Text = "WAIT"
>>>>>
>>>>> Cheers
>>>>> Daniel
>>>>> --
>>>>> http://www.danielmoth.com/Blog/
>>>>>
>>>>>
>>>>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>>>>> news:%23jov%(E-Mail Removed)...
>>>>>> Chris,
>>>>>>
>>>>>> Maybe the problem is that I'm trying to set the property twice within
>>>>>> one
>>>>>> proc in the tick event???
>>>>>>
>>>>>> Here's the code:
>>>>>> This timer fires every five minutes. IT makes about a thirty second
>>>>>> trip
>>>>>> to the server to grab fresh data....I want to alert the user in a
>>>>>> more
>>>>>> pronouced way that they need to leave the device cradled until after
>>>>>> the
>>>>>> sync.....
>>>>>>
>>>>>> Private Sub tmrRefreshData_Tick(ByVal sender As System.Object, ByVal
>>>>>> e As
>>>>>> System.EventArgs) Handles tmrRefreshData.Tick
>>>>>> Dim objLocalDB As New LocalDB
>>>>>> Dim ds As New DataSet
>>>>>> Dim blnUsersRetrieved As Boolean
>>>>>>
>>>>>> lblWait.Text = "WAIT"
>>>>>> Try
>>>>>> CheckConnection()
>>>>>> Catch ex As Exception
>>>>>> 'MsgBox("Unable to verify connection")
>>>>>>
>>>>>> End Try
>>>>>>
>>>>>>
>>>>>> If g_blnConnected = True And g_blnLocalDBExists = True Then
>>>>>> Try
>>>>>> ds = objLocalDB.GetUsers
>>>>>> If ds.Tables(0).Rows.Count > 0 Then
>>>>>> blnUsersRetrieved = True
>>>>>> g_dsUsers = ds
>>>>>> End If
>>>>>>
>>>>>> If g_blnLocalDBExists And blnUsersRetrieved Then
>>>>>> Try
>>>>>> RefreshLocalDatabase()
>>>>>> Catch ex As SqlServerCe.SqlCeException
>>>>>> MsgBox(ex.Message.ToString)
>>>>>> Finally
>>>>>>
>>>>>> End Try
>>>>>> End If
>>>>>> Catch ex As Exception
>>>>>>
>>>>>> End Try
>>>>>>
>>>>>> End If
>>>>>>
>>>>>>
>>>>>>
>>>>>> lblWait.Text = " "
>>>>>>
>>>>>> Dim TimeNow As DateTime = DateTime.Now
>>>>>> Dim MyString As String = TimeNow.ToString("hh:mm")
>>>>>>
>>>>>> lblLastSync.Text = "Last Sync : " & MyString.TrimStart("0")
>>>>>> End Sub
>>>>>>
>>>>>> "Chris Tacke, eMVP" <(E-Mail Removed)> wrote in message
>>>>>> news:%(E-Mail Removed)...
>>>>>>> Post some code.
>>>>>>>
>>>>>>> --
>>>>>>> Chris Tacke
>>>>>>> Co-founder
>>>>>>> OpenNETCF.org
>>>>>>> Has OpenNETCF helped you? Consider donating to support us!
>>>>>>> http://www.opennetcf.org/donate
>>>>>>>
>>>>>>>
>>>>>>> "Harry Simpson" <(E-Mail Removed)> wrote in message
>>>>>>> news:%(E-Mail Removed)...
>>>>>>>>I am trying to display/hide a label either by visible or
>>>>>>>>manipilating the
>>>>>>>>Left property.
>>>>>>>>
>>>>>>>> Why would a label not appear at runtime on a panel. I've right
>>>>>>>> clicked
>>>>>>>> and done the Bring to Front deal.
>>>>>>>>
>>>>>>>> I even used a label that I am able to change the text in. When I
>>>>>>>> add
>>>>>>>> code to change the text, it won't work for the original function
>>>>>>>> either.
>>>>>>>> What's going on! I've been trying to solve this all afternoon..
>>>>>>>>
>>>>>>>> TIA
>>>>>>>> Harry
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>

>>
>>

>



 
Reply With Quote
 
Simon Wilkinson via DotNetMonster.com
Guest
Posts: n/a
 
      17th Mar 2005
Hi guys,

I'm not sure if this is relevant to what you're talking about, but I've had
a similar issue previously where I wanted to change the label text, and I
solved it using the following:

lblTest.Text = "Text1"
lblTest.Refresh()

lblTest.Text = "Text2"
lblTest.Refresh()

--
Message posted via http://www.dotnetmonster.com
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2003 Label Report - Text Position On Label Question Dermot Microsoft Access Reports 7 4th Dec 2008 02:06 AM
Word prints label in center of page instead of on select label =?Utf-8?B?R01vbQ==?= Microsoft Word Document Management 1 30th Aug 2006 09:23 PM
adding a new color label to the label list for Microsoft Outlook 2 =?Utf-8?B?Q1NTIFRlY2g=?= Microsoft Outlook Calendar 1 21st Jul 2006 05:57 PM
Receiving #error when creating mailing label using label wizard =?Utf-8?B?RGVlX0RlZQ==?= Microsoft Access 2 1st Dec 2005 02:36 PM
How to change mailing label size in existing label document =?Utf-8?B?R3Jhbm55QW5u?= Microsoft Word Document Management 1 2nd Dec 2004 06:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:58 PM.