Сейчас это выглядит так:
TCPClientSocket.RemoteHost="127.0.0.1"
TCPClientSocket.LocalPort=112
TCPClientSocket.Listen(Me)
Как сделать так, что бы компонент знал на какой форме он находиться без "ручного" указания ему

It turns out that the solution is even simpler. All that is needed is to reference the Site property of the base component and get the designer host information from it. Here are the steps to achieve the goal:
Create a new item in your Windows Project and use the "Component" template.
Switch to "Code View" and add the following code:
Imports System.ComponentModel.Design
…
Private _form As Form
Private Sub GetFormInstance() ' called from constructor
Dim _host As IDesignerHost = Nothing
If MyBase.Site IsNot Nothing Then _host = _
CType(MyBase.Site.GetService(GetType(IDesignerHost)), IDesignerHost)
If _host IsNot Nothing Then _form = CType(_host.RootComponent, Form)
End Sub
Open the Designer code (you may have to toggle the "Show All Files" button at the top of the Solution Explorer and then expand the files under the component to see the file with the .Designer extension).
At the end of the default constructor add a call to the GetFormInstance function. The code should look like this:
<System.Diagnostics.DebuggerNonUserCode()> _
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Added by developer
GetFormInstance()
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1