I am almost embarrassed to ask this question, but seeing how I have been trying one thing after another in Visual Studio, I thought I would ask. I am developing a Windows Form using C# where I am trying to populate a list_box with items it receives from a readmultiple webservice call.
I cannot seem to find a good code example for this in a Windows Form setting.
Thank you all in advance for your help.
I did find the below example for VB however not for c# :-)
Dim ws As New Mywebservice.Customer_Binding
ws.UseDefaultCredentials = True
ws.Url = "http://localhost:7047/DynamicsNAV/WS/CRONUS_International_Ltd/Page/Customer"
Dim Cust(100) As Mywebservice.Customer
Dim wsFields As New Mywebservice.Customer_Fields
Dim wsfilter(1) As Mywebservice.Customer_Filter
wsfilter(1).Field = wsFields.Name
wsfilter(1).Criteria = "J*"
Cust = ws.ReadMultiple(wsfilter, "", 0)
For Counter = LBound(Cust) To UBound(Cust)
Me.ListBox1.Items.Add(Counter & ": " + Cust(Counter).No & "-> " & Cust(Counter).Name)
Next Counter
Comments
Well are you using any ajax or special tools to populate your list box with web services? Or is it a just a list box?
First of all I create a Web Reference (Add Service Reference -> Advanced -> Add Web Reference) to the customer page and call it CustomerPageRef, I also added a using statement and then the C# code would be:
good luck
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I added a data grid control to Form1 bound to the customer page web service.
If I added the Name field to the datagrid, I would get errors. The error was in standard code:
this.Name = "Form1";
It appears that having a field Name conflicted with the property of the form. VS was confused.
The errors in VS were:
Error 1 Cannot implicitly convert type 'string' to 'System.Windows.Forms.DataGridViewTextBoxColumn'
Warning 2 'Customer_Lookup.Form1.Name' hides inherited member 'System.Windows.Forms.Control.Name'. Use the new keyword if hiding was intended.
When I remove the Name field from the Datagrid, no errors.
So, to fix this, in the Edit Columns dialog, I selected the Name field, then changed the (Name) property to CustName. Now all is good and the form runs.
Hopefully, this will help someone get around the issue of using NAV "Name" fields in VS.
Corollary- Build and idiot proof system and nature will build a better idiot.