Filling a Windows Froms Combo Box From a .Net Web Service
Posted on 2006-07-14
I am developing a VB.Net app that uses a SQL Server Backend, a .Net Web Service as the middle tier and a VB.Net Windows Forms app as the front end. It seems that everyone assumes that if you are using a Web service that your front end will be ASPX or at least browser based. To date I have not been able to find a single example that shows a web service consumed by a Windows forms app. (I digress here only to ask that if anyone knows of a good resource for Web service to Windows Forms app info please include. – this includes Books, Web sites, and Magazines etc.)
Ok, now on to the meat so to speak. I have a Customer class in my web service; it contains the usual stuff Name, address etc. I have a web method GetCustomer that will return a class Customer if you provide the Customer ID. (The Customer Class has all the necessary code to retrieve a customer from the backend.)
Now that works but I cannot find any windows forms examples on how to return a list of Names and customer ID’s to load into a combo so the user can select a customer by name.
I tried creating a collection with just Name and ID as properties. But it will not show up as a web method. And any examples seem to state that I must include the code for the entire collection in my front end to even think about using it. (didn’t have to do that for the class!?!)
Thought about using a List array but I can’t find any examples that aren’t ASPX based.
Besides, I like the whole collection idea better because it seems cleaner to me.
I’m giving out 500 points for this question because I think this will become a running dialog over the next few days.
Thanks in advance!