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. Late binding problem in C# (urgent)

Late binding problem in C# (urgent)

Scheduled Pinned Locked Moved C#
csharphelpwpfwcf
3 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.
  • S Offline
    S Offline
    Sheel Gohe
    wrote on last edited by
    #1

    This is a C# 2005 Problem: I have an MDIForm and 5 child forms in my project. what i have to do is, during MDI Form's "MdiChildActivate" event I have to set some value to private a variable in my active child form. But when i write a statement like this : this.ActiveMdiChild.childVariableMode="0"; I get an error-"No defination For childVariableMode found in activemdichild". In vb.net i can do this by: dim a as object a=me.ActiveMdiChild a.childVariableMode="0" But i C# if i do same as VB.NET i get the same error, please solve my problem.I am in very hurry, my whole project is depended on this. Thanks in Advance. Sheel Sheel Gohe Sheel Gohe

    S S 2 Replies Last reply
    0
    • S Sheel Gohe

      This is a C# 2005 Problem: I have an MDIForm and 5 child forms in my project. what i have to do is, during MDI Form's "MdiChildActivate" event I have to set some value to private a variable in my active child form. But when i write a statement like this : this.ActiveMdiChild.childVariableMode="0"; I get an error-"No defination For childVariableMode found in activemdichild". In vb.net i can do this by: dim a as object a=me.ActiveMdiChild a.childVariableMode="0" But i C# if i do same as VB.NET i get the same error, please solve my problem.I am in very hurry, my whole project is depended on this. Thanks in Advance. Sheel Sheel Gohe Sheel Gohe

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      The best way is to cast ActiveMdiChild down to the class which has the childVariableMode variable. If ActiveMdiChild can be one of several classes, where only some have the variable defined, then your best bet is to declare a base class from which all MDI children derive from and place the childVariableMode variable in the base class. A quick hack would be to use reflection to do what you want. Simply query for the variables in the object using the variable name ("childVariableMode") and then set the value of the variable. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      1 Reply Last reply
      0
      • S Sheel Gohe

        This is a C# 2005 Problem: I have an MDIForm and 5 child forms in my project. what i have to do is, during MDI Form's "MdiChildActivate" event I have to set some value to private a variable in my active child form. But when i write a statement like this : this.ActiveMdiChild.childVariableMode="0"; I get an error-"No defination For childVariableMode found in activemdichild". In vb.net i can do this by: dim a as object a=me.ActiveMdiChild a.childVariableMode="0" But i C# if i do same as VB.NET i get the same error, please solve my problem.I am in very hurry, my whole project is depended on this. Thanks in Advance. Sheel Sheel Gohe Sheel Gohe

        S Offline
        S Offline
        Stefan Troschuetz
        wrote on last edited by
        #3

        The ActiveMdiChild property returns a Form object which contains no definition for childVariableMode. To access this variable you have to cast the returned form object to one of your child form types. Because you don't know which one is currently the active child, you need a way to treat all child form types equally. One possibility is to define a common base type for all child forms which contains the childVariableMode property and then cast the return value of ActiveMdiChild property to this type. Another way is to define an interface with the childVariableMode which then gets implemented by all child forms and in this case cast the return value of ActiveMdiChild property to interface type.


        www.troschuetz.de

        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