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. C# How to disable focus??

C# How to disable focus??

Scheduled Pinned Locked Moved C#
questioncsharptutorial
5 Posts 3 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.
  • A Offline
    A Offline
    adnanh75
    wrote on last edited by
    #1

    How can I disable focus on few buttons?

    S M 2 Replies Last reply
    0
    • A adnanh75

      How can I disable focus on few buttons?

      S Offline
      S Offline
      Sebastian Schneider
      wrote on last edited by
      #2

      Select your button in the form designer. Switch "Properties" to the "Events"-Mode. Then scroll to the "Focus"-Section and give some method name for "Enter". I used "button1_FocusEnter". This will create an empty method in which you put one line: someOtherControl.Focus; You can also prevent users from "tabbing" through your control by setting "TabStop" to false. With the "coded" solution, the button will never keep focus, the someOtherControl will receive Focus instead. That will not prevent anyone from pressing that button, though. If you want users NOT to press a button, disable it. If you set TabStop to false, the control still gets focused if someone presses it. If you combine both ways, the button will never KEEP focus, but users can still press it and trigger it and stuff. Cheers Sebs

      A 1 Reply Last reply
      0
      • S Sebastian Schneider

        Select your button in the form designer. Switch "Properties" to the "Events"-Mode. Then scroll to the "Focus"-Section and give some method name for "Enter". I used "button1_FocusEnter". This will create an empty method in which you put one line: someOtherControl.Focus; You can also prevent users from "tabbing" through your control by setting "TabStop" to false. With the "coded" solution, the button will never keep focus, the someOtherControl will receive Focus instead. That will not prevent anyone from pressing that button, though. If you want users NOT to press a button, disable it. If you set TabStop to false, the control still gets focused if someone presses it. If you combine both ways, the button will never KEEP focus, but users can still press it and trigger it and stuff. Cheers Sebs

        A Offline
        A Offline
        adnanh75
        wrote on last edited by
        #3

        Great, thank you for beeing patient and explaning me in this way.. thanks :)

        1 Reply Last reply
        0
        • A adnanh75

          How can I disable focus on few buttons?

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

          Another, perhaps easier way is to create a button that's not selectable per-se. Create a new class InertButton that inherits Button. In the c'tor you just add the following line:

          SetStyle(ControlStyles.Selectable, false);

          That's it. Use this InertButton exactly the same way you would use a regular button. Regards, mav

          A 1 Reply Last reply
          0
          • M mav northwind

            Another, perhaps easier way is to create a button that's not selectable per-se. Create a new class InertButton that inherits Button. In the c'tor you just add the following line:

            SetStyle(ControlStyles.Selectable, false);

            That's it. Use this InertButton exactly the same way you would use a regular button. Regards, mav

            A Offline
            A Offline
            adnanh75
            wrote on last edited by
            #5

            Thanx mav :)

            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