I have list, i want to convert it to autoCompleteStringCollection.. And I don't want use foreach.
_textbox.AutoCompleteMode = AutoCompleteMode.Append;
_textbox.AutoCompleteSource = AutoCompleteSource.CustomSource;
_textbox.AutoCompleteCustomSource = user.GetNameUsers() as AutoCompleteStringCollection;
Note user.GetNameUsers() is list.
Code doesn't work, it become null.
Thank you
as
operator trys to coerce your List<string> into anAutoCompleteStringCollection
, butas
only succeeds if the runtime types match (it won't try any user defined conversions), and the runtime types ofList<string>
andAutoCompleteStringCollection
are not the same, so it returns null instead. – Euphoniousthis.textbox.AutoCompleteCustomSource.AddRange(new string[] {"anytext","another one"});
– Wadewadell