Hi my name is vishal for past 2 days i have been breaking my head on How to add an invisible Panel control and how to add winsock controls inside it in c# windows forms?
i have 3 winsock controls in my form named:Form1 in c# windows forms.
1st winsock control named:
Winsock1,Protocol:
sckTCPProtocol,visible:
true
2nd winsock control named:
sckServer,Protocol:
sckTCPProtocol,Visible:
true
3rd winsock control named:
axWinsock5,Protocol:
sckTCPProtocol,Visible:
true
I cannot use classes associated with
System.Net.Sockets in c# windows forms and that i have to use only winsock controls for this purpose since it is my
BOSS's orders.
I am at the process of creating a control array named:
sckClient and initializing it to my winsock control named:
axWinsock5.
Given below is my c# code of creating control array(sckClient) in Form1:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Diagnostics;
namespace DRRS_Socket_Application
{
public partial class Form1 : Form
{
private AxMSWinsockLib.AxWinsock axWinsock1;
private AxMSWinsockLib.AxWinsock[] sckClient = new AxMSWinsockLib.AxWinsock[20];
public Form1()
{
InitializeComponent();
sck = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sck.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
}
private void Form1_Load(object sender, EventArgs e)
{
int x;
for (x = 0; x < 20; x++)
{
sckClient[x]=new AxMSWinsockLib.AxWinsock();
((System.ComponentModel.ISupportInitialize)(this.axWinsock5)).BeginInit();
sckClient[x].Enabled = true;
axWinsock5.EndInit();
StartListen();
}
}
private void StartListen()
{
sckServer.Close();
sckServer.LocalPort = 25000;
sckServer.Listen();
}
My first question is have i correctly created a control array named:
sckClient and initialized it to winsock control named:
axWinsock5 in c# windows forms.
I not questioning the person/member of this forum who has helped me / shared his knowledge generously with me. I am just questioning myself that have i created control array named:
sckClient and initialized it to winsock control named:
axWinsock5?
I am asking this question because after having done some research on how to correctly create and manipulate control array of winsock control in c# windows forms i got an opinion that i should create an invisible Panel control named:
Panel1,add my winsock controls(
Winsock1,
sckServer,
axWinsock5) to/inside
Panel1 and that axWinsock5.EndInit(); should be after EndInit() property of Panel1(panel control) in c# windows forms.
Am i going in correct direction of correctly creating control array(
sckClient) and initializing it to winsock control(
axWinsock5) in my form(
Form1) in c# windows forms?
If so Can anyone help me please on how to create invisible panel control in c# windows forms with my Winsock controls(Winsock1,sckServer,axWinsock5) inside my panel control in c# windows forms?
Can anyone at least send me a sample on how to create a invisible panel control with winsock controls inside it in c# windows forms?
Can anyone help me/guide me please to solve my problem! Any help/guidance in solving of this problem would be greatly appreciated.