4

对于用户控件 TextBox,我正在创建类似的属性AutoCompleteCustomSourceAutoCompleteMode并且AutoCompleteSource

public virtual AutoCompleteStringCollection AutoCompleteCustomSource 
{ 
    get { return txtLocl.AutoCompleteCustomSource; } 
    set { txtLocl.AutoCompleteCustomSource = value; } 
}

public virtual AutoCompleteMode AutoCompleteMode 
{ 
    get { return txtLocl.AutoCompleteMode; } 
    set { txtLocl.AutoCompleteMode = value; } 
}

public virtual AutoCompleteSource AutoCompleteSource 
{ 
    get { return txtLocl.AutoCompleteSource; } 
    set {txtLocl.AutoCompleteSource=value;} 
}

我正在这样创建,但是对于AutoCompleteCustomSource字符串集合,我遇到了这样的错误。我告诉你错误 在此处输入图像描述

我想要的是我在下图中显示

在此处输入图像描述

4

1 回答 1

1

请试试这个,我希望它会工作:

public string[] AutoCompleteCustomSource
{
    get
    {
        List<string> lStringList = new List<string>();
        foreach (string lval in this.mEkaTextBox.AutoCompleteCustomSource)
        {
            lStringList.Add(lval);
        }
        return lStringList.ToArray();
    }
    set
    {
        txtLocl.AutoCompleteCustomSource.AddRange(value);
    }
}
于 2014-04-27T19:24:29.533 回答