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