Solved

refresh label

Posted on 2008-10-29
6
1,423 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Article by: Nadia
Linear search (searching each index in an array one by one) works almost everywhere but it is not optimal in many cases. Let's assume, we have a book which has 42949672960 pages. We also have a table of contents. Now we want to read the content on p…
When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

806 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