简体   繁体   中英

I am getting error like “constructor on type 'system.string' cannot found” for a User Control in C#?

For a usercontrol TextBox i am creating properties like AutoCompleteCustomSource , AutoCompleteMode and 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;} 
}

I am creating like that but i am getting error like this for AutoCompleteCustomSource string collection. i show you the error 在此输入图像描述

and what i want is i show in the below figure

在此输入图像描述

Please try this, I hope it will work:

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);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM