Home > Net >  In c # call each other between the two projects
In c # call each other between the two projects

Time:12-31

Hello, everyone,
The same solution, the two projects, is generally MainFrm ClassLibrary1 in the project of the class in the function (number, etc.); If want to control in ClassLibrary1 MainFrm interface of the control information (such as printed in the Listbox control), with a delegate is how to achieve?

CodePudding user response:

Internet is not a pile of
https://www.cnblogs.com/sjqq/p/6917497.html

CodePudding user response:

First of all,
An interface to call a class library, is normal,
But a class library, the coupling of the matter call interface, is not normal,

Then said the method,
You pass a control object, do not need to entrust

CodePudding user response:

You always call the class library the following class, is a class method, the method is the return value and return value judgment in MainForm you receive if return 1, after you perform print is not good?

CodePudding user response:

This is called a circular reference, if there is problem should, in turn, think about your ideas. Don't go down.

CodePudding user response:

refer to the second floor is nu month god reply:
first of all,
An interface to call a class library, is normal,
But a class library, the coupling of the matter call interface, is not normal,

Then said the method,
You pass a control object, do not need to entrust

Yes, the control object is the best way, if you want to use the entrusted how to achieve good?

CodePudding user response:

reference rabbit family - second brother reply: 3/f
you always call the class library the following class, is a class method, the method is the return value and return value judgment in MainForm you receive if return 1, after you perform print is not good?

If a class method in the execution of content is more, want to print the details of the process, through the return value is not good,

CodePudding user response:

You need to show the information to the ListBox, there is a movement called "output to the ListBox", this action should not be done in class, because it is possible because of the ListBox display effect is not good for the output to RichTextBox, then have to change to the class,
If you print the move on the UI, but class only responsible for output need to print information, then you can casually on the UI in the handling of information,

Can class defined in another event, event information only throw need to "print", then the UI to subscribe to this event,
When the UI receive event information, then you want to how to deal with

CodePudding user response:

 class A 
{
Public Action Act;

Void the Do ()
{
Act ();
}
}

The class Form2: Form
{
Public void M ()
{
A. A=new A ();
A.A ct=()=& gt;
{
This. Label1. Text="aaa";
};
}
}

CodePudding user response:

references 9 f Bridge_go response:
 class A 
{
Public Action Act;

Void the Do ()
{
Act ();
}
}

The class Form2: Form
{
Public void M ()
{
A. A=new A ();
A.A ct=()=& gt;
{
This. Label1. Text="aaa";
};
}
}


Thinking this right, the building itself to,

Upstairs said transferring control instead, said a circular reference is wrong,

In a word, don't take yourself when the fairy, do you know other people how to do? Don't know to people outside your processing,

Transfer control? You know what he passed for you, I give you pass a CEF Broswer, you know what the people outside want to get??
Circular references, each other what you have to do, there is no circular references, fan entrusted enforcement exchange, he did in his territory, didn't let you reference
  •  Tags:  
  • C#
  • Related