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. AcceptButton for a UserControl?

AcceptButton for a UserControl?

Scheduled Pinned Locked Moved C#
tutorialquestion
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.
  • W Offline
    W Offline
    WetRivrRat
    wrote on last edited by
    #1

    I'm building a usercontrol that has multiple buttons on it, and i need to set one of them as the accept button, but i can't find anything about how to do this. From what i can see it is only accessable from the Forms.Form not Forms.UserControl... Is this entirely the truth, or can I still somehow set this to work so it validates against my "Ok" button, when someone hits enter. string Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful + " people."; Why is common sense such an un-common comodity?

    L 1 Reply Last reply
    0
    • W WetRivrRat

      I'm building a usercontrol that has multiple buttons on it, and i need to set one of them as the accept button, but i can't find anything about how to do this. From what i can see it is only accessable from the Forms.Form not Forms.UserControl... Is this entirely the truth, or can I still somehow set this to work so it validates against my "Ok" button, when someone hits enter. string Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful + " people."; Why is common sense such an un-common comodity?

      L Offline
      L Offline
      Luis Alonso Ramos
      wrote on last edited by
      #2

      Your user control can't have an AcceptButton property because what happens if there are multiple user controls on the same form and all have that property set? which is the one that counts? A workaround is to expose a public read only property named something like DefaultButton, and have it return a reference to your OK Button. Then, the form can set its AcceptButton property to that reference. Or the other way around, make the form pass a reference to itself to the user control, so it can set the form's AcceptButton property (I like the first way better). -- LuisR


      Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

      The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005

      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