Windowsクライアント版 検索アプリケーション
C# postanMain.cs
C# postanList.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Postan.jp.co.est.webservice;
using System.Data;
namespace Postan
{
///
/// PostanList 検索結果を一覧表示し、その中から1つ選ぶ。
///
public class PostanList : System.Windows.Forms.Form
{ //キャンセルボタン
private System.Windows.Forms.DataGrid dgAddList;
private System.Windows.Forms.Button btnClose; //検索結果一覧
///
/// 必要なデザイナ変数です。
///
private System.ComponentModel.Container components = null;
public PostanList()
{
//
// Windows フォーム デザイナ サポートに必要です。
//
InitializeComponent();
//
// TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
//
}
///
/// 使用されているリソースに後処理を実行します。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
///
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(PostanList));
this.dgAddList = new System.Windows.Forms.DataGrid();
this.btnClose = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dgAddList)).BeginInit();
this.SuspendLayout();
//
// dgAddList
//
this.dgAddList.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.dgAddList.CaptionVisible = false;
this.dgAddList.DataMember = "";
this.dgAddList.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgAddList.Name = "dgAddList";
this.dgAddList.ReadOnly = true;
this.dgAddList.RowHeaderWidth = 20;
this.dgAddList.Size = new System.Drawing.Size(592, 392);
this.dgAddList.TabIndex = 2;
this.dgAddList.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dgAddList_Navigate);
//
// btnClose
//
this.btnClose.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
this.btnClose.BackColor = System.Drawing.SystemColors.Control;
this.btnClose.Location = new System.Drawing.Point(480, 400);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(104, 24);
this.btnClose.TabIndex = 3;
this.btnClose.Text = "閉じる";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// PostanList
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(247)), ((System.Byte)(150)));
this.ClientSize = new System.Drawing.Size(592, 430);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnClose,
this.dgAddList});
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "PostanList";
this.Text = "ぽすたん 候補一覧";
((System.ComponentModel.ISupportInitialize)(this.dgAddList)).EndInit();
this.ResumeLayout(false);
}
#endregion
internal FindItem SelectItems( FindItem[] fiItems )
{
//検索結果をテーブル表示
DataTable dtFindItems = new DataTable("FindItems");
DataColumn dcWork;
DataRow drWork;
FindItem flReturn;
dcWork = new DataColumn("郵便番号");
dtFindItems.Columns.Add(dcWork);
dcWork = new DataColumn("旧郵便番号");
dtFindItems.Columns.Add(dcWork);
dcWork = new DataColumn("住所");
dtFindItems.Columns.Add(dcWork);
dcWork = new DataColumn("読み");
dtFindItems.Columns.Add(dcWork);
for(int i=0; i < fiItems.Length; i++ )
{
drWork = dtFindItems.NewRow();
drWork["郵便番号"] =fiItems[i].ZipCode;
drWork["旧郵便番号"] =fiItems[i].OldZipCode;
drWork["住所"] =fiItems[i].Kanji;
drWork["読み"] =fiItems[i].Yomi;
dtFindItems.Rows.Add(drWork);
}
dgAddList.PreferredColumnWidth = (dgAddList.Width - dgAddList.RowHeaderWidth) / 5;
dgAddList.SetDataBinding(dtFindItems, "");
Show();
flReturn = fiItems[dgAddList.CurrentRowIndex]; //選択された項目を返す
return flReturn;
}
private void btnClose_Click(object sender, System.EventArgs e)
{
Close();
}
private void dgAddList_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
}
}
}