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. how to determine if you control is inside a panel or not?

how to determine if you control is inside a panel or not?

Scheduled Pinned Locked Moved C#
tutorialcsharpwinformshelpquestion
8 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.
  • T Offline
    T Offline
    TheCardinal
    wrote on last edited by
    #1

    how do you check if your, for example datagridview control or any control is inside a panel or not? using winforms any help is highly appreciated :D

    Life - Dreams = Job TheCardinal BenPOS Systems

    D G T 3 Replies Last reply
    0
    • T TheCardinal

      how do you check if your, for example datagridview control or any control is inside a panel or not? using winforms any help is highly appreciated :D

      Life - Dreams = Job TheCardinal BenPOS Systems

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      YourControl.Parent property will tell that.

      It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

      G 1 Reply Last reply
      0
      • T TheCardinal

        how do you check if your, for example datagridview control or any control is inside a panel or not? using winforms any help is highly appreciated :D

        Life - Dreams = Job TheCardinal BenPOS Systems

        G Offline
        G Offline
        Greg Chelstowski
        wrote on last edited by
        #3

        yourControl.Parent.GetType();

        gives you the type of your Parent control, if you are interested in that. Without the .GetType() you'll get the control itself. Check if it's a panel like this:

        if(yourControl.Parent is Panel)
        {
        MessageBox.Show("Hooray");
        }

        var question = (_2b || !(_2b));

        1 Reply Last reply
        0
        • D dan sh

          YourControl.Parent property will tell that.

          It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

          G Offline
          G Offline
          Greg Chelstowski
          wrote on last edited by
          #4

          Honestly, one day in this forum, I'm not gonna get beaten to the punch. It's like tenth time in a row that's happened. ;>

          var question = (_2b || !(_2b));

          D 1 Reply Last reply
          0
          • T TheCardinal

            how do you check if your, for example datagridview control or any control is inside a panel or not? using winforms any help is highly appreciated :D

            Life - Dreams = Job TheCardinal BenPOS Systems

            T Offline
            T Offline
            TheCardinal
            wrote on last edited by
            #5

            thanks guys :D cheers

            Life - Dreams = Job TheCardinal BenPOS Systems

            1 Reply Last reply
            0
            • G Greg Chelstowski

              Honestly, one day in this forum, I'm not gonna get beaten to the punch. It's like tenth time in a row that's happened. ;>

              var question = (_2b || !(_2b));

              D Offline
              D Offline
              dan sh
              wrote on last edited by
              #6

              :~:confused: Cannot understand it.

              It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

              G 1 Reply Last reply
              0
              • D dan sh

                :~:confused: Cannot understand it.

                It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

                G Offline
                G Offline
                Greg Chelstowski
                wrote on last edited by
                #7

                You answered two minutes before me, therefore "beat me to the punch". And it seems like that has happened like 10 times to me already ;> "Someone beat me to the punch."

                var question = (_2b || !(_2b));

                D 1 Reply Last reply
                0
                • G Greg Chelstowski

                  You answered two minutes before me, therefore "beat me to the punch". And it seems like that has happened like 10 times to me already ;> "Someone beat me to the punch."

                  var question = (_2b || !(_2b));

                  D Offline
                  D Offline
                  dan sh
                  wrote on last edited by
                  #8

                  Oh... :doh:

                  It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

                  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