Solved

refresh label

Posted on 2008-10-29
6
1,443 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

One of Google's most recent algorithm changes affecting local searches is entitled "The Pigeon Update." This update has dramatically enhanced search inquires for the keyword "Yelp." Google searches with the word "Yelp" included will now yield Yelp a…
Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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