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. calling method/event of one form from another

calling method/event of one form from another

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

    Hi All I have three forms in my application Form1 (main form), Form2 and Form3. Is there any easy way to call method or event which is on Form1 from Form3.In my application there is a method in form1 which is showing records on ListView of Form1 from a file. In Form3 I am adding two records in the file and after that form3 and form2(which is intermediatery form) both are closed and Form1 becomes the active form.Now I want to call a method or event so that two records are added to the ListView without calling Page load. I can not declare that method/event as public due to security reason. protected internal is okay. Searching on the net confused me and i did not understood anything. Please guide. Thanks Regards The SK

    C 1 Reply Last reply
    0
    • S Sandeep Kalra

      Hi All I have three forms in my application Form1 (main form), Form2 and Form3. Is there any easy way to call method or event which is on Form1 from Form3.In my application there is a method in form1 which is showing records on ListView of Form1 from a file. In Form3 I am adding two records in the file and after that form3 and form2(which is intermediatery form) both are closed and Form1 becomes the active form.Now I want to call a method or event so that two records are added to the ListView without calling Page load. I can not declare that method/event as public due to security reason. protected internal is okay. Searching on the net confused me and i did not understood anything. Please guide. Thanks Regards The SK

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Sandeep Kalra wrote:

      Is there any easy way to call method or event which is on Form1 from Form3

      Yes. It is essentially the same as passing a value (a property is just syntactic sugar for a get and set method). Passing Values between Forms with C# and VB.NET examples[^]

      Sandeep Kalra wrote:

      Page load.

      Page? Is this a web application?

      Sandeep Kalra wrote:

      I can not declare that method/event as public due to security reason. protected internal is okay.

      The accessor levels of methods has nothing to do with security. If you want security you might want to look into areas such as CAS (Code Access Security). If someone wants to to call your method then they can do so quite easily using reflection. So, making something private, protected or internal has zero security associated with it.

      Sandeep Kalra wrote:

      Searching on the net confused me and i did not understood anything.

      Then this may turn into a conversation.

      *Developer Day Scotland - Free community conference Delegate Registration Open

      S 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Sandeep Kalra wrote:

        Is there any easy way to call method or event which is on Form1 from Form3

        Yes. It is essentially the same as passing a value (a property is just syntactic sugar for a get and set method). Passing Values between Forms with C# and VB.NET examples[^]

        Sandeep Kalra wrote:

        Page load.

        Page? Is this a web application?

        Sandeep Kalra wrote:

        I can not declare that method/event as public due to security reason. protected internal is okay.

        The accessor levels of methods has nothing to do with security. If you want security you might want to look into areas such as CAS (Code Access Security). If someone wants to to call your method then they can do so quite easily using reflection. So, making something private, protected or internal has zero security associated with it.

        Sandeep Kalra wrote:

        Searching on the net confused me and i did not understood anything.

        Then this may turn into a conversation.

        *Developer Day Scotland - Free community conference Delegate Registration Open

        S Offline
        S Offline
        Sandeep Kalra
        wrote on last edited by
        #3

        1.Yes. It is essentially the same as passing a value (a property is just syntactic sugar for a get and set method). Passing Values between Forms with C# and VB.NET examples[^] I have studied above topic but I do not have to pass values. 2. Page? Is this a web application? Its a windows based application. 3.The accessor levels of methods has nothing to do with security. If you want security you might want to look into areas such as CAS (Code Access Security). If someone wants to to call your method then they can do so quite easily using reflection. So, making something private, protected or internal has zero security associated with it. I did not knew about that.So Is this mean that I have to use CAS to improve security of my application. Please guide Thanks Regards THE SK

        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