你怎麼樣繼承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