Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
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.
Posted
Comments
gggustafson 1-Jul-14 12:08pm    
What does a Panel have to do with WinSockets? Are you allowing users to access them through the UI? Also because it is not visible, I see no purpose for the Panel. Please provide the reasoning behind this Panel.
Member 10248768 2-Jul-14 0:10am    
Dear Mr.gggustafson
Thank you for replying to my query on such short notice. I have only one question: Have i correctly created control array of winsock control named:sckClient and correctly assigned it to winsock control named:axWinsock5 in my form named:Form1 in c# windows forms? That is what i need to know! If not Tell me,help me/guide me on how to create control array of winsock control named:sckClient and initializing it to winsock control named: axWinsock5 in form named:Form1 in c# windows forms? Reply please?! I am waiting for your reply Sir!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900