Solved

refresh label

Posted on 2008-10-29
6
1,414 Views
Last Modified: 2012-06-27
hello experts,
i have an application whereby a label is reading the content of a text file. i added a refresh button which should refresh the content of the label. what is the code for refreshing koz i already tried lblDisplay.refresh without success
-------------------------Reading-----------------------------  Private Sub mnuOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOpen.Click
 

 If lstDrafts.FocusedItem.Index = 0 Then

            Dim reader As StreamReader

            reader = File.OpenText("\Drafts\MessageNum0.txt")

            Dim contents As String = reader.ReadToEnd()

            lblDisplay.Text = contents

            lblDisplay.Visible = True

            reader.Close()

        End If

end sub

-------------------------Refreshing button------------------------------

    Private Sub mnuRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuRefresh.Click

        lblDisplay.Refresh()

        lblDisplay.Visible = False

    End Sub

Open in new window

0
Comment
Question by:Alv45525
  • 4
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
dampsey earned 125 total points
ID: 22838579
Refresh command, just redraws the current content of the label. It does not read the file again.

What you should do is, call the reading function again.
Private Sub mnuOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOpen.Click

 

 If lstDrafts.FocusedItem.Index = 0 Then

       lblDisplay.Text = ReadTheFileContent()

       lblDisplay.Visible = True

 End If

end sub
 

private function ReadTheFileContent() as string

Dim reader As StreamReader

            reader = File.OpenText("\Drafts\MessageNum0.txt")

            Dim contents As String = reader.ReadToEnd()

            reader.Close()

            return contents

end function
 

    Private Sub mnuRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuRefresh.Click

       lblDisplay.Text = ReadTheFileContent()

   End Sub

Open in new window

0
 

Author Comment

by:Alv45525
ID: 22838778
hello dampsey, i tried it but still after reading the label does not get refresh
0
 
LVL 8

Expert Comment

by:dampsey
ID: 22838793
are you sure you change the content of the correct file and save it before refreshing?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Alv45525
ID: 22838804
look i have two txt files listed in a treeview. when the first 1 is selected,
label.visible= true and it displays content of txt 1

if button close(refresh) is selected, the label should clear its content, that is the txt1 and hide again.

when user select second txt file, label appears again and displays content of txt 2
0
 

Author Comment

by:Alv45525
ID: 22838867
thx 4 ur help dampsey..but i've been able to do it...

it wrote

lblDisplay.text = nothing
0
 

Author Closing Comment

by:Alv45525
ID: 31511558
Thx 4 ur help...i appreciate that u too the time 4 answering me
thX loads

tke care.N hpe to here frm u!
tke care
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Prime numbers are natural numbers greater than 1 that have only two divisors (the number itself and 1). By “divisible” we mean dividend % divisor = 0 (% indicates MODULAR. It gives the reminder of a division operation). We’ll follow multiple approac…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now