Solved

refresh label

Posted on 2008-10-29
6
1,451 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

719 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