你怎么样继承WebProxy
到,例如,WebProxyEx
并实现IList
接口,排序(预计实现IList或IListSource接口的对象)是一个先决条件,使用列表框的.DataSource
财产。就像下面:
class WebProxyEx : WebProxy, IList
{
private object[] _contents = new object[8];
private int _count;
public WebProxy w;
public WebProxyEx(string address)
{
_count = 0;
w = new WebProxy(address);
this.Add(w.Address.Authority);
}
...
而且使用它像:
ListBox lb;
public Form1()
{
InitializeComponent();
WebProxyEx w = new WebProxyEx("127.0.0.1:80");//Use your sub class
lb = new ListBox();
this.Controls.Add(lb);
lb.DataSource = w;//assign the datasource.
//lb.DisplayMember = "Address.Authority"; //Automatically gets added in the WebProxEx constructor.
}
给出了列表框下面的输出:
127.0.0.1
我用了萨韦的做法该OP并创建了一个包含我的WebProxy对象和一个str的新对象这给了我的代理权。感谢您的回答。 – 2010-11-25 17:21:17