c# “chat1”方法没有采用“3”个参数的重载
}using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using System.Net.Sockets;
using Model;
using System.Collections;
using System.Threading;
namespace WindowsApplication1
{
public partial class success : Form
{
//TreeView
NetworkStream ns;
string wo;
private NetworkStream NetStream;
Thread Listener;
private TcpListener TcpListener;
Hashtable allChatForms;
byte[] mss;
private int IconMode;
public success()
{
InitializeComponent();
}
private static string username;
public static string Username
{
get { return success.username; }
set { success.username = value; }
}
private void success_Load(object sender, EventArgs e)
{
login logon = new login();
logon.ShowDialog();
//添加初始化
wenbenkuang.ShowLines = false;
wenbenkuang.ShowRootLines = false;
//添加父节点
TreeNode root1 = new TreeNode("我的好友");
TreeNode root4 = new TreeNode("陌生人");
TreeNode root5 = new TreeNode("黑名单");
//添加子节点
TreeNode root11 = new TreeNode("x");
TreeNode root12 = new TreeNode("y");
TreeNode root21 = new TreeNode("x");
TreeNode root22 = new TreeNode("y");
//添加到NODS集合
wenbenkuang.Nodes.Add(root1);
wenbenkuang.Nodes.Add(root4);
wenbenkuang.Nodes.Add(root5);
//父节点添加到子节点中去
root1.Nodes.Add(root11);
root1.Nodes.Add(root12);
//listView2.View = View.Tile;
//listView3.View = View.Tile;
yonghuming.Text = username;
//webBrowser1.Navigate("http://wap.baidu.com");
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
mss = Encoding.UTF8.GetBytes("refreshU^");
ns.Write(mss, 0, mss.Length);
ns.Flush();
}
public int NodeLevel(TreeNode n)//找出树中当前节点的级数
{
int i = 0;
while (!(n.Parent == null))
{
n = n.Parent;
i += 1;
}
return i;
}
private void zt_SelectedIndexChanged(object sender, EventArgs e)
{
if (zt.Text == "我在线上")
{
label3.Text = zt.Text;
}
else if (zt.Text == "Q我吧")
{
label3.Text = zt.Text;
}
else if (zt.Text == "离开")
{
label3.Text = zt.Text;
}
else if (zt.Text == "忙碌")
{
label3.Text = zt.Text;
}
else if (zt.Text == "请勿打扰")
{
label3.Text = zt.Text;
}
else if (zt.Text == "离线")
{
label3.Text = zt.Text;
}
}
private void wenbenkuang_AfterSelect(object sender, TreeViewEventArgs e)
{
if (NodeLevel(e.Node).ToString() == "0")
{
//选中父节点
//你要处理的事件
}
else if (NodeLevel(e.Node).ToString() == "1")
{
//选中子节点
chat1.ActiveForm.Activate();
chat1 user1 = new chat1();
user1.ShowDialog();
}
else if (NodeLevel(e.Node).ToString() == "2")
{
//选中孙节点
//你要处理的事件
}
}
}
}
private void showChatForm(object sender, EventArgs e)
{
Button btn = sender as Button;
chat1 c = allChatForms[btn.Text] as chat1;
if (c != null)
c.Visible = true;
else
{
chat1 myc = new chat1(ns, wo, btn.Text);
myc.Show();
allChatForms.Add(btn.Text, myc);
}
这是什么原因啊 --------------------编程问答-------------------- chat1(ns, wo, btn.Text);
没有三个参数的构造函数 --------------------编程问答-------------------- --------------------编程问答-------------------- chat1 myc = new chat1(ns, wo, btn.Text);
意思你的 chat1 类中必须要有一个带3个参数的构造函数声明,可能像下面这样
class chat1
{
public chat1(NetworkStream n,string str,string str2)
{
// ...
}
}
--------------------编程问答-------------------- 1楼:
可是这怎么怎么写呢?我找到这个原因了,如果把chat1(ns, wo, btn.Text);没有三个参数的构造函数chat1里面的代码删除就没有数据流进行传输了
补充:.NET技术 , C#