Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Label Visibility under ButtonClick EventHandler

Label Visibility under ButtonClick EventHandler

Scheduled Pinned Locked Moved C#
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rahul83
    wrote on last edited by
    #1

    Hi Friends, At the click of button i am fetching data from back end which takes a time..so before fetching i am making a label visible with a message saying "Please Wait"..as it can be clear from code below.. private void btnShowDetails_Click(object sender, EventArgs e) { lblShowMessage.visible=true; FetchRecords(); lblShowMessage.visible=false; } but that label is not getting visible at all..what could be the problem..plz assist me in this regard. Thanks, Rahul Agarwal

    M 1 Reply Last reply
    0
    • R Rahul83

      Hi Friends, At the click of button i am fetching data from back end which takes a time..so before fetching i am making a label visible with a message saying "Please Wait"..as it can be clear from code below.. private void btnShowDetails_Click(object sender, EventArgs e) { lblShowMessage.visible=true; FetchRecords(); lblShowMessage.visible=false; } but that label is not getting visible at all..what could be the problem..plz assist me in this regard. Thanks, Rahul Agarwal

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Hi! That's simple: Your btnShowDetails_Click method is running on the main UI thread that's responsible for repainting the form. Between making lblShowMessage visible and hiding it again, it's busy fetching some records, so it doesn't have time to repaint the form. Once the button click handler is through, the form can get repainted, but then the label is invisible again. The better solution would be to put FetchRecords in a separate thread and let the UI thread handle just the UI.

      Regards, mav -- Black holes are the places where God divided by 0...

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups