GcAddressBoxCellの機能は、「JPAddress for .NET(以下、JPAddress)」を利用して実現されており、検索機能を利用するためにはJPAddressのインストールおよび開発ライセンスが必要です。
詳細については「JPAddress for .NETとの連携」を参照してください。
GcAddressBoxCellの入力フィールドには次の9つのフィールドが設定されており、これらのフィールドオブジェクトを使って書式が設定されています。
 |
GcAddressBoxCellでは、これらのフィールドを追加したり削除したりすることはできません。区切りフィールドを非表示にしたい場合には、各フィールドのTextプロパティを削除します。 |
AutoFilterプロパティをTrueに設定すると、GcAddressBoxCellのすべてのフィールドで候補リストが入力した文字によりフィルタリングされます。なお、オートフィルタ機能を動作させるには、各フィールドのDropDownEnabledプロパティがTrueに設定され候補リストのドロップダウン表示が有効である必要があります。
以下のサンプルコードは、オートフィルタ機能を有効にします。
Imports GrapeCity.Win.MultiRow
Imports InputManCell = GrapeCity.Win.MultiRow.InputMan
Dim GcAddressBoxCell1 = New InputManCell.GcAddressBoxCell()
GcAddressBoxCell1.Name = "GcAddressBoxCell1"
' オートフィルタを有効にします。
GcAddressBoxCell1.AutoFilter = True
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {GcAddressBoxCell1})
GcMultiRow1.RowCount = 10
using GrapeCity.Win.MultiRow;
using InputManCell = GrapeCity.Win.MultiRow.InputMan;
InputManCell.GcAddressBoxCell gcAddressBoxCell1 = new InputManCell.GcAddressBoxCell();
gcAddressBoxCell1.Name = "gcAddressBoxCell1";
// オートフィルタを有効にします。
gcAddressBoxCell1.AutoFilter = true;
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { gcAddressBoxCell1});
gcMultiRow1.RowCount = 10;
GcAddressBoxCellのオートフィルタ機能は、ひらがなを入力した時点でフィルタリングが開始します。
例えば、「み」と入力すると文字の変換や確定を行う前に、下記のように「み」で始まる「宮城県」「三重県」「宮崎県」が候補リストに表示されます。この状態で上下矢印キーによりリストから選択でき、Enterキーを押下すると県名を入力することができます。
- 「み」と入力すると、フィルタリングされた県名が表示されます。
- 下矢印キーを押下します。
- Enterキーを押下します。
このほか、「みやぎ」と続けて文字を入力し候補リストから選択することも可能です。下図のように候補リストが一つしかない場合、漢字変換を行わなくてもEnterキーの押下により項目を選択できます。

 |
- Windows 7以前のOSでは、文字の変換を行いIMEの変換リストが表示されているとき、オートフィルタリストは非表示となります。
- Windows 8以降のOSでは、文字の変換を行いIMEの変換リストが表示されているとき、IMEの変換リストの下にオートフィルタリストが表示されます。
|
GcAddressBoxCellでは選択可能な都道府県を設定できます。PrefectureFilterプロパティでどの県を対象として検索を行うかどうかを設定できます。
以下はGcAddressBoxCellで関東地方の県のみの検索と入力を行う場合のサンプルコードです。
Imports GrapeCity.Win.MultiRow
Imports InputManCell = GrapeCity.Win.MultiRow.InputMan
Dim GcAddressBoxCell1 = New InputManCell.GcAddressBoxCell()
GcAddressBoxCell1.Name = "GcAddressBoxCell1"
' 関東地方のみを検索対象として入力を許可します。
GcAddressBoxCell1.PrefectureFilter = "茨城県,栃木県,群馬県,埼玉県,千葉県,東京都,神奈川県"
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {GcAddressBoxCell1})
GcMultiRow1.RowCount = 10
using GrapeCity.Win.MultiRow;
using InputManCell = GrapeCity.Win.MultiRow.InputMan;
InputManCell.GcAddressBoxCell gcAddressBoxCell1 = new InputManCell.GcAddressBoxCell();
gcAddressBoxCell1.Name = "gcAddressBoxCell1";
// 関東地方のみを検索対象として入力を許可します。
gcAddressBoxCell1.PrefectureFilter = "茨城県,栃木県,群馬県,埼玉県,千葉県,東京都,神奈川県";
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { gcAddressBoxCell1});
gcMultiRow1.RowCount = 10;

入力された住所と検索結果は以下のプロパティで取得します。
- SelectedPrefecture(「都道府県」の「都道府県コード(JIS X 0401)」「都道府県名」「都道府県名カナ」の情報をGrapeCity.Win.Editors.RegionInfo型で取得します。)
- SelectedCity(「市区町村」の情報を「市区町村コード(JIS X 0402)」「市区町村名」「市区町村名カナ」の情報をGrapeCity.Win.Editors.RegionInfo型で取得します。)
- SelectedTown(「町域」の「町域名」「町域名カナ」の情報をGrapeCity.Win.Editors.RegionInfo型で取得します。)
- SelectedArea(「丁目」の「郵便番号」「丁目」「丁目カナ」の情報をGrapeCity.Win.Editors.RegionInfo型で取得します。)
- InputtedBlockCode(入力された「番地」の情報を取得します。)
- Value(GcAddressBoxCellに入力された情報をすべて取得します。)
- ZipCode(GcAddressBoxCellに入力された情報から検索された郵便番号を取得します。)
次のサンプルコードでは、GcAddressBoxCellの値と結果を出力します。
Private Sub GcMultiRow1_CellLeave(sender As Object, e As CellEventArgs) Handles GcMultiRow1.CellLeave
If TypeOf GcMultiRow1.CurrentCell Is InputManCell.GcAddressBoxCell Then
Dim cell As InputManCell.GcAddressBoxCell = GcMultiRow1.CurrentCell
' 都道府県の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.SelectedPrefecture:" + cell.SelectedPrefecture.ToString())
' 市区町村の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.SelectedCity:" + cell.SelectedCity.ToString())
' 町域の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.SelectedTown:" + cell.SelectedTown.ToString())
' 丁目の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.SelectedArea:" + cell.SelectedArea.ToString())
' 番地の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.BlockCode.Text:" + cell.InputtedBlockCode)
' 全ての住所の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.Value:" + cell.Value)
' 住所から検索した郵便番号の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.ZipCode:" + cell.ZipCode)
End If
End Sub
private void gcMultiRow1_CellLeave(object sender, CellEventArgs e)
{
if (gcMultiRow1.CurrentCell is InputManCell.GcAddressBoxCell)
{
InputManCell.GcAddressBoxCell cell = (InputManCell.GcAddressBoxCell)gcMultiRow1.CurrentCell;
// 都道府県の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.SelectedPrefecture:" + cell.SelectedPrefecture);
// 市区町村の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.SelectedCity:" + cell.SelectedCity);
// 町域の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.SelectedTown:" + cell.SelectedTown);
// 丁目の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.SelectedArea:" + cell.SelectedArea);
// 番地の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.BlockCode.Text:" + cell.InputtedBlockCode);
// 全ての住所の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.Value:" + cell.Value);
// 住所から検索した郵便番号の取得
System.Diagnostics.Debug.WriteLine("GcAddressBoxCell.ZipCode:" + cell.ZipCode);
}
}
【出力結果例】
GcAddressBoxCell.SelectedPrefecture:01,北海道,ホッカイドウ
GcAddressBoxCell.SelectedCity:01101,札幌市中央区,サッポロシチュウオウク
GcAddressBoxCell.SelectedTown:大通西,オオドオリニシ
GcAddressBoxCell.SelectedArea:0600042,1丁目,1チョウメ
GcAddressBoxCell.BlockCode.Text:2-3
GcAddressBoxCell.Value:北海道札幌市中央区大通西1丁目2-3
GcAddressBoxCell.ZipCode:0600042