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. Help with simple user control

Help with simple user control

Scheduled Pinned Locked Moved C#
csharphtmlwinformscomhelp
3 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.
  • C Offline
    C Offline
    Charlie Williams
    wrote on last edited by
    #1

    :confused: I am reasonably competent with C# (please note that "reasonably" is a very subjective term), but don't have much (read: any) experience building user controls. The (very simple) user control I am having problems with contains two panels, three labels and a combobox. Which of the two panels is visible depends on whether the control is currently in edit mode. Currently I have the control go into edit mode and thus change which panel is visible when any control in the user control is clicked. I am looking for a clean way of doing the opposite: I can't seem to find an event that will fire when a user clicks on another part of the form. Therefore, the control still looks like it's being edited while the user is off doing something else entirely. I'm sure the answer will be sufficiently simple so as to make me feel foolish for asking, but it's really starting to irritate me. Any help would be appreciated. Charlie Here I am. Love me.

    H 1 Reply Last reply
    0
    • C Charlie Williams

      :confused: I am reasonably competent with C# (please note that "reasonably" is a very subjective term), but don't have much (read: any) experience building user controls. The (very simple) user control I am having problems with contains two panels, three labels and a combobox. Which of the two panels is visible depends on whether the control is currently in edit mode. Currently I have the control go into edit mode and thus change which panel is visible when any control in the user control is clicked. I am looking for a clean way of doing the opposite: I can't seem to find an event that will fire when a user clicks on another part of the form. Therefore, the control still looks like it's being edited while the user is off doing something else entirely. I'm sure the answer will be sufficiently simple so as to make me feel foolish for asking, but it's really starting to irritate me. Any help would be appreciated. Charlie Here I am. Love me.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      You should be able to handle the LostFocus event (or Leave event) of the UserControl itself, since the GotFocus and Enter events bubble up. This way, when any control in your UserControl (and thus the UserControl itself) loose focus, you can switch your panels' visibility.

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      C 1 Reply Last reply
      0
      • H Heath Stewart

        You should be able to handle the LostFocus event (or Leave event) of the UserControl itself, since the GotFocus and Enter events bubble up. This way, when any control in your UserControl (and thus the UserControl itself) loose focus, you can switch your panels' visibility.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        C Offline
        C Offline
        Charlie Williams
        wrote on last edited by
        #3

        Thank you for the response. It turned out that by making the panel visible, but not giving focus to any of the controls on it, that the original control still had the focus and as such, no LostFocus event would fire :-O Your reinforcement that I was handling the correct event allowed me to stop looking araound aimlessly and figure out what the problem was. Thank you. Charlie Here I am. Love me.

        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