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. Getting protected controls using reflection

Getting protected controls using reflection

Scheduled Pinned Locked Moved C#
question
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
    Chals
    wrote on last edited by
    #1

    Hi, I am inspecting an assembly that has a form, and this form has some controls that are inherited from a BaseForm class. Using GetFields I get to know its controls. However, the inherited controls do not show. I have set BindingFlags as follows: BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; Am I missing something, any ideas? Thanks in advance.

    M 1 Reply Last reply
    0
    • C Chals

      Hi, I am inspecting an assembly that has a form, and this form has some controls that are inherited from a BaseForm class. Using GetFields I get to know its controls. However, the inherited controls do not show. I have set BindingFlags as follows: BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; Am I missing something, any ideas? Thanks in advance.

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #2

      Try BindingFlags.FlattenHierarchy as well. Otherwise, I guess you'd have to get the fields on the base type(s) as well -- Type.BaseType Marc

      Thyme In The Country

      People are just notoriously impossible. --DavidCrow
      There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
      People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith

      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