Hi! I have a function that I am calling thru a service, but I am having a problem with the type it returns: this is the function: I just put the relevant part for simplicity
PublicSharedFunction getNames(ByVal prefixAsString)As List(OfString)Dim mylistAs List(OfString) =New List(OfString)
'loop thru data and add items
mylist.Add(row.Title)
getNames = mylist
EndFunction
on the client form I have :
PrivateSub Form1_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)HandlesMyBase.LoadDim mydataAsNew AutoCompleteStringCollection()mydata.Add(proxy.GetNames(txtAutoComplete.Text).ToString())
txtDrop.AutoCompleteCustomSource = mydata
EndSub
I am getting an error that system.autocompletecollection can't be converted to 1- dimential array
Hi
James25:
mydata.Add(proxy.GetNames(txtAutoComplete.Text).ToString())
What are you trying to acheive by the obove code?
In case you want the concatenation of all the strings in the list, loop through the list and then concatenate them or return the concatenated string.
If this doesn't solve your problem, in which line no do you get the error or can you post the complete exception here?
Hi James,
Based on my understanding, you want to create auto complete ComboBox with the data you get from the service in the windows application. If I have misunderstood you, please feel free to let me know.
I agree with the member above. When we use the List(Of String) ToString method, the return is the type of the List. We can loop this List and add the item to AutoCompleteStringCollection. For example:
List<string> lt = proxy.GetNames(txtAutoComplete.Text);
AutoCompleteStringCollection data = new AutoCompleteStringCollection();
for (int i = 0; i < lt.Count; i++)
{
data.Add(lt[i]);
}
comboBox1.AutoCompleteCustomSource = data;
I hope this helps.
Thank you! Got it working!!
0 comments:
Post a Comment