Hi all,
i have trouble with changing text value of textbox on runtime. I use this
control to display process information about sending e-mail per smtp. I use
external component Imports devBiz.Net.Mail
which can hadle events by sending mail.
AddHandler client.OnProgre ss, AddressOf Progress
I have function, which can calculate status of process in percent
Public Sub Progress(ByVal sender As Object, ByVal e As ProgressEventAr gs) Dim percent As Integer = _ CType((CType(e. Position / e.Length * 100, Double)), Integer) txtMailStatus.T ext = percent End Sub
Progress Function is called every time, when sending status is changed,
function calculates correctly 'percent' value, but on form i cannot change
default text. Can you anybody help me? Below i attached all source code for
this form.
I have no onLoad Function for this form defined. Is it problem? How can I
changed text value of text box on runtime?
Than you for your help
Radek Budar
Imports System.Text
Imports devBiz.Net.Mail
Public Class frmRegistration Request
Dim frmMailStatusFo rm as New frmMailSendingS tatus
Private Sub sendRequest( ByVal sender As System.Object, ByVal e As
System.EventArg s) _
Handles btnSendRegReq.C lick
Dim strPrijmeni as String
Dim strJmeno as String
Dim strMesto as String
Dim strEmail as String
Dim sql as String
Dim firstRun as Date
Dim regNrUser as Double
Dim mailMsg As MailMessage = New MailMessage
mailMsg.From.EM ail = "aa*@yyy.cz "
mailMsg.To.Add( "XXX","YY*@sezn am.cz")
Dim now as Date
strPrijmeni = txtPrijmeni.Tex t
strJmeno = txtJmeno.Text
strMesto = txtMesto.Text
strEmail = txtEmail.Text
Dim sb As New StringBuilder()
sb.Append(strPr ijmeni)
sb.Append(",")
sb.Append(strJm eno)
sb.Append(",")
sb.Append(strMe sto)
sb.Append(",")
sb.Append(strEm ail)
sb.Append(",")
sb.Append(regNr User)
mailMsg.Subject = "test - " & now
mailMsg.Body = sb.ToString
Dim client As smtp = New smtp
client.Host = "smtp.seznam.cz "
client.Port = 25
' We will capture the progress event, so we attach an event handler
AddHandler client.OnProgre ss, AddressOf Progress
txtMailStatus.V isible = True
'E-mail sending
Try
client.SendMess age(mailMsg)
Catch ex As System.Net.Mail .SmtpException
txtMailStatus.F oreColor = Color.Red
txtMailStatus.T ext = "Failure!"
MsgBox("Odeslán í e-mailu se nezdařilo, zkontrolujte připojení k internetu!"
& vbNewLine & vbNewLine + ex.Message, MsgBoxStyle.Exc lamation, "Chyba při
odesílání registračního e-mailu")
Exit Sub
Finally
End Try
txtMailStatus.F oreColor = Color.Green
txtMailStatus.t ext = "Done...success !"
stavRegistrace = 3
Me.Close
End Sub
Public Sub Progress(ByVal sender As Object, ByVal e As ProgressEventAr gs)
Dim percent As Integer = _
CType((CType(e. Position / e.Length * 100, Double)), Integer)
txtMailStatus.T ext = percent
End Sub
End Class 8 2860
"Radek Budař" <ra*********@as ei.cz> schrieb Progress Function is called every time, when sending status is changed, function calculates correctly 'percent' value, but on form i cannot change default text. Can you anybody help me? Below i attached all source code for this form.
What do you mean with "default text"? I guess, "txtMailStatus. Text =
percent" is executed but the display isn't updated, right? If this is the
case: There can be two different reasons depending on how the smtp class
works (see it's documentation).
If the OnProgress event is raised in a different thread, you must call
txtMailStatus.I nvoke to marshal updating the textbox to the right thread.
Only the thread that created a control is allowed to access it.
If it's not raised in a different thread, the display isn't updated because
your application is still busy in "client.SendMes sage(mailMsg)" and there's
no time to update the display. In earlier Win versions, you could force
updating the display by calling txtMailStatus.R efresh but this can fail
under WinXP after the application is not "responsive " after few seconds. In
this case you can either create your own thread to send the mail - then you
do have to call txtMailStatus.I nvoke to update the textbox - or, you can use
a simple workaround by calling the PeekMessage API function (faking the
responsiveness of your application) in addition to calling
txtMailStatus.R efresh.
Armin
> What do you mean with "default text"? I guess, "txtMailStatus. Text = percent" is executed but the display isn't updated, right? If this is the
Yes, correct. Thank you for your advice, i will try it as soon as possible.
Can you say me still one...? How can I find, that onProgress event is raised
in a different thread...? Sorry, I am rookie :-)
Thanks
"Armin Zingler" <az*******@free net.de> píse v diskusním príspevku
news:Ob******** ******@TK2MSFTN GP14.phx.gbl... "Radek Budař" <ra*********@as ei.cz> schrieb Progress Function is called every time, when sending status is changed, function calculates correctly 'percent' value, but on form i cannot change default text. Can you anybody help me? Below i attached all source code for this form.
What do you mean with "default text"? I guess, "txtMailStatus. Text = percent" is executed but the display isn't updated, right? If this is the case: There can be two different reasons depending on how the smtp class works (see it's documentation).
If the OnProgress event is raised in a different thread, you must call txtMailStatus.I nvoke to marshal updating the textbox to the right thread. Only the thread that created a control is allowed to access it.
If it's not raised in a different thread, the display isn't updated because your application is still busy in "client.SendMes sage(mailMsg)" and there's no time to update the display. In earlier Win versions, you could force updating the display by calling txtMailStatus.R efresh but this can fail under WinXP after the application is not "responsive " after few seconds. In this case you can either create your own thread to send the mail - then you do have to call txtMailStatus.I nvoke to update the textbox - or, you can use a simple workaround by calling the PeekMessage API function (faking the responsiveness of your application) in addition to calling txtMailStatus.R efresh.
Armin
"Radek Budar" <ra*********@as ei.cz> schrieb What do you mean with "default text"? I guess, "txtMailStatus. Text = percent" is executed but the display isn't updated, right? If this is the
Yes, correct. Thank you for your advice, i will try it as soon as possible. Can you say me still one...? How can I find, that onProgress event is raised in a different thread...? Sorry, I am rookie :-)
In the documentation on the class. Or: In Sub Progress, examine the return
value of Me.InvokeRequir ed. If it is True, the event is raised from a
different thread.
Armin
Hallo,
i tried it and...Me.Invoke Required is 'false', also it is not running in
separate thread (i muss say FORTUNATELLY, because use of Invoke method in
now out of my capacity :-). But I made any changes in my Progress procedure,
so text box is now updating...When , after every text box updating, show
message box, text in text box is updated. I dont know why but i know, that
is for me unacceptable. Here is core:
Public Sub Progress(ByVal sender As Object, ByVal e As ProgressEventAr gs)
Dim percent As Integer = _
CType((CType(e. Position / e.Length * 100, Double)), Integer)
txtMailStatus.T ext = percent
MsgBox("Status: " & percent)
End Sub
When I delete 'MsgBox("Status : " & percent)', no update of text box
'txtMailStatus' is displayed!
Any advice now, please...
Best regards
Radek Budar
"Armin Zingler" <az*******@free net.de> píse v diskusním príspevku
news:uZ******** *****@TK2MSFTNG P11.phx.gbl... "Radek Budar" <ra*********@as ei.cz> schrieb > What do you mean with "default text"? I guess, "txtMailStatus. Text > = percent" is executed but the display isn't updated, right? If > this is the
Yes, correct. Thank you for your advice, i will try it as soon as possible. Can you say me still one...? How can I find, that onProgress event is raised in a different thread...? Sorry, I am rookie :-)
In the documentation on the class. Or: In Sub Progress, examine the return value of Me.InvokeRequir ed. If it is True, the event is raised from a different thread.
Armin
Hallo
i tried InvokeRequired and result is 'False'. So, case one, other thread,
is out. I made a little change in my procedure 'progress', after every text
box change, i display message box. Message box displays percent value. After
every display of message box, is text box also updated! I dont know why...?
After delete MessageBox, is no text changed!
Here is my changed procedure. Can you give me advice, what is incorrenc or
why after display message box is text box also updated?
Public Sub Progress(ByVal sender As Object, ByVal e As ProgressEventAr gs)
Dim percent As Integer = _
CType((CType(e. Position / e.Length * 100, Double)), Integer)
txtMailStatus.T ext = percent
MsgBox("Status: " & percent)
End Sub
"Armin Zingler" <az*******@free net.de> píse v diskusním príspevku
news:uZ******** *****@TK2MSFTNG P11.phx.gbl... "Radek Budar" <ra*********@as ei.cz> schrieb > What do you mean with "default text"? I guess, "txtMailStatus. Text > = percent" is executed but the display isn't updated, right? If > this is the
Yes, correct. Thank you for your advice, i will try it as soon as possible. Can you say me still one...? How can I find, that onProgress event is raised in a different thread...? Sorry, I am rookie :-)
In the documentation on the class. Or: In Sub Progress, examine the return value of Me.InvokeRequir ed. If it is True, the event is raised from a different thread.
Armin
"Radek Budar" <ra*********@as ei.cz> schrieb Hallo i tried InvokeRequired and result is 'False'. So, case one, other thread, is out. I made a little change in my procedure 'progress', after every text box change, i display message box. Message box displays percent value. After every display of message box, is text box also updated! I dont know why...? After delete MessageBox, is no text changed! Here is my changed procedure. Can you give me advice, what is incorrenc or why after display message box is text box also updated?
If you display the messagebox, the application has time to update the
display, including the textbox. To solve this, see my comment "If it's not
raised in a different thread..."
If you're interested in basic information: http://msdn.microsoft.com/library/en...sagequeues.asp http://msdn.microsoft.com/library/en...tdraw_1xd1.asp
Armin
Thanks for rich information and for links. I solved the problem follower:
Public Sub Progress(ByVal sender As Object, ByVal e As ProgressEventAr gs)
Dim percent As Integer = _
CType((CType(e. Position / e.Length * 100, Double)), Integer)
txtMailStatus.T ext = percent
Me.Refresh
End Sub
I tested it on WXP, and it looks right :-)
Thank you still one and wish happy new year
Radek Budar
"Armin Zingler" <az*******@free net.de> píse v diskusním príspevku
news:OH******** *****@tk2msftng p13.phx.gbl... "Radek Budar" <ra*********@as ei.cz> schrieb Hallo i tried InvokeRequired and result is 'False'. So, case one, other thread, is out. I made a little change in my procedure 'progress', after every text box change, i display message box. Message box displays percent value. After every display of message box, is text box also updated! I dont know why...? After delete MessageBox, is no text changed! Here is my changed procedure. Can you give me advice, what is incorrenc or why after display message box is text box also updated?
If you display the messagebox, the application has time to update the display, including the textbox. To solve this, see my comment "If it's not raised in a different thread..."
If you're interested in basic information: http://msdn.microsoft.com/library/en...sagequeues.asp
http://msdn.microsoft.com/library/en...tdraw_1xd1.asp
Armin
"Radek Budar" <ra*********@as ei.cz> schrieb Thanks for rich information and for links. I solved the problem follower:
Public Sub Progress(ByVal sender As Object, ByVal e As ProgressEventAr gs) Dim percent As Integer = _ CType((CType(e. Position / e.Length * 100, Double)), Integer) txtMailStatus.T ext = percent Me.Refresh End Sub
I tested it on WXP, and it looks right :-)
Good to hear, but if you cover and uncover your Form, or click onto it once,
the progress might be gone. This might take some seconds til the OS
considers your application to be hung (although it isn't).
Thank you still one and wish happy new year
Wish you the same.
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew |
last post by:
I use conditional compiler constants, set through the VBA IDE in
Tools, <projectname> Properties, that I refer to throughout my code to
control which code is used during development, and which during
production. Usually, this only wraps code used to control quitting
the whole app versus just shutting a form, but it can also control
many other things.
However, as part of the build before delivering an update, I have to
remember to...
|
by: Leo |
last post by:
I created a user control which is some text contained in a HtmlTable.
I put this control into main form. I would like to have the ability to
move this control around in the main form. I think one way to do this
is to change the style of this control at runtime ("Left:xx px; Top:xx
px"). Another way is to move the HtmlTable in the control (i.e. change
the style of it). However I couldn't figure out how to let it work. At
design time, I...
|
by: Joel D Kraft |
last post by:
I'm using controls in my ASP.NET application from a couple of vendors.
Between the vendors and thier versioning, I've set up subfolders under my bin
directory:
bin
bin\Infragistics\v5.2
bin\RadControls\v5.3
Under 2.0b2, I had the following setup in my web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
by: planetthoughtful |
last post by:
Hi All,
I have an ASP.NET page that displays a GridView control based on an
ObjectDataSource control.
I'm wondering if it's possible to base the ObjectDataSource in question
on a parameter query, with the ability to set the parameter value at
run time (in the Page_Load event, perhaps?)?
Basically, I'd like to display records in the GridView based on values
|
by: zeng.hui.stephen |
last post by:
I download the demo
http://msdn.microsoft.com/msdnmag/issues/02/10/cuttingedge/. I
inherite the demo, and write my code.
I want to use Hook to monitor C++ Edit change. I use a C# form
containing a Edit(textbox) and button to test at first. When I change
text in Edit or press button to setText value, I want to monitor the
change event.
But the event code always return 0, why?
| |
by: ngpost1 |
last post by:
I have a Crystal Reports.Net report being generated from my C#
application. I would like to change the background color of the
details section (not the text mind you) of the report on certain
conditions. For example if the value of the 'Meeting Number' is
greater than 100 the background color of the details section will be
light yellow, otherwise it will be white. There will be multiple
records in this reports so one (or a few) detail...
|
by: Sankalp |
last post by:
Hi,
I am using VB 2005. My application has many data bound controls. The
connection is stored in the app.config file.
I want the application to start with a default connection string and
while during the runtime, the user can click on a button and change the
connection string without exiting the application.
I would really appreciate any sort of help.
|
by: Radu |
last post by:
Hi, I have a "select" control named "cboSelectScorecardType", defined
as
<select id="cboSelectScorecardType"
size="1"
runat="server">
</select>
which shows a list of files on my drive. It does not post back, nor do
I want it to. After the user selects a document in the combo, I want a
|
by: TG |
last post by:
Hi!
I am trying to export only the visible columns from a datagridview in
my windows form in VB 2008.
Should't it be no comma after the first row where the headers are?
Also should there be a comma at the last row?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |