c# - Clicking a button on one form while clicking on a different form -


I have two programs, both different names, which run independently of each other, I click on a button I would like to call the incident to be done on a form if it is being executed by clicking on a button on the other.

I was able to do this by publicizing in VB , referring to DLL in Form 2 and namespace.form1 Call by clicking on .button_click but it can not work how to do this in C #.

You must pass the reference to the form2 object ( which is executed by clicking on For launching the button in the RCGI application ) for the form1 object.

If Form 2 is a separate add-in ( provided by a third party ) and any API functions, then I guess what you want to achieve Too difficult to do If you have created this add-in, you can expose a function so that other apps can click the button on this add-in.

In addition, the mode of communication between the two add-ins also depends on how the add-ins is being loaded in the ARCGS application (in-process or out-process) depending on it , You can either call directly to another function or you may have to go through the Remoting, RPC, etc.

The above answer is based on my understanding of how the Open button can be clicked on the other add-in and can not be related to this specific case.

Edit: Added after the comment of OP below

P> As you can see both projects Code and can update them, it's good, we can do whatever we want

After referring to Form 1 item 1 of Form 1, using all the methods of the system Will be enabled (only if you click the button in Form 2, it will not be accessible)

One Create a new project, which will act as a base, and an interface will be IOutsideCallable

  Interface IOutsideCallable {void PerformButtonClick (); }  

Now, in your projects of Form 1 and Form 2, implement the above interface in Form 2 in the above project

 
class form2: System .Windows Forms.Form, IOutsideCallable {// Other Form Codes Public void PerformButtonClick () {btn_Click (empty, empty); }}

In Form 1, create a variable to point to the IOutsideCallable type of object. You can pass Form 2 object either through the constructor or property of Form 1. (As you mentioned in your comment that you do not know the order in which constructors have passed, you can use the property)

Then, in Form 1

  class form1: System.Windows.Forms.Form {// Form 1 Code Judicial IOutsideCallable Form2Variable {get; Set; } Zero foo () // This function in which you will click the button Form2 {if (Form2Variable! = Null) Form2Variable.PerformButtonClick (); }}  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -