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. Index of Button

Index of Button

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

    Hi, I have a panel and inside that panel there are 3 buttons which I have put them drag and drop inside that panel, now I add dynamically button4 inside panel which it's left is left of button3+button3.width, so when i want to check first index of controls inside panel then i get button which i added dinamically, instead of button4 i except to get button1. So why i am getting this dinamically added button as first button of panel and i dont get button1 as first button inside panel? Can anyone explain me this? Best regards.

    B 1 Reply Last reply
    0
    • C cdpsource

      Hi, I have a panel and inside that panel there are 3 buttons which I have put them drag and drop inside that panel, now I add dynamically button4 inside panel which it's left is left of button3+button3.width, so when i want to check first index of controls inside panel then i get button which i added dinamically, instead of button4 i except to get button1. So why i am getting this dinamically added button as first button of panel and i dont get button1 as first button inside panel? Can anyone explain me this? Best regards.

      B Offline
      B Offline
      BillWoodruff
      wrote on last edited by
      #2

      At design-time: When you drag-drop Controls onto a Form, or into a container Control, like a Panel, they are written into the Designer.cs file in the order put on the Form. When the WinForm "engine" lays out the Controls, then the last one created is effectively "in front of" the other Controls. The ControlsCollection of a Form, or other container Control, is ordered by the z-order: so the last Control added, which is in front, is first. If you change the z-order of a Control at design-time, its order in the ControlsCollection changes. Use 'BringToFront() it goes to the start of the ControlsCollection; use 'SendToBack(), and it goes to the end. You can observe what happens at design-time by opening the Designer.cs file and examining the place in the file where Controls are added: change the z-order of one of the Controls you've put on the Form, and look at how the Designer.cs file has changed. At run-time: Controls you create and add to a Form, or container Control, are added to the end of the ControlsCollection of their container. If you use 'BringToFront() on a dynamically created Control before you add it to the ControlsCollection of a container, it will have no effect, but will not cause an error. If you use 'BringToFront() on a dynamically created Control after you add it to the ControlsCollection of a container, the Control will be at the 0th. element of the ControlsCollection.

      Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview

      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