《Microsoft Visual C# .NET 2003开发技巧大全》源代码
源代码在线查看: 17.6.txt
Listing 17.6 Consuming Web Services with Windows Forms
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace _7_LotteryClient
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label lbl1;
private System.Windows.Forms.Label lbl3;
private System.Windows.Forms.Label lbl4;
private System.Windows.Forms.Label lbl5;
private System.Windows.Forms.Label lbl2;
private System.Windows.Forms.Button btnGo;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lbl1 = new System.Windows.Forms.Label();
this.lbl3 = new System.Windows.Forms.Label();
this.lbl4 = new System.Windows.Forms.Label();
this.lbl5 = new System.Windows.Forms.Label();
this.lbl2 = new System.Windows.Forms.Label();
this.btnGo = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
// forms designer generated code removed
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnGo_Click(object sender, System.EventArgs e)
{
localhost.LotteryWebService gen=new localhost.LotteryWebService();
int[] result = gen.GenerateNumbers( 5, 0, 100, false );
lbl1.Text = result[0].ToString();
lbl2.Text = result[1].ToString();
lbl3.Text = result[2].ToString();
lbl4.Text = result[3].ToString();
lbl5.Text = result[4].ToString();
}
}
}