ArcObjects Library Reference  

IdentifyDlg

About the RSS weather layer Sample

[C#]

IdentifyDlg.cs

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ESRI.ArcGIS.esriSystem;

namespace RSSWeatherLayer
{
  /// <summary>
  /// The IdentifyDlg is used by the Identify object to display the identify results
  /// </summary>
	public class IdentifyDlg : System.Windows.Forms.Form
	{
    private System.Windows.Forms.ListView listView1;
    private System.Windows.Forms.ColumnHeader columnField;
    private System.Windows.Forms.ColumnHeader columnValue;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public IdentifyDlg()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
      this.listView1 = new System.Windows.Forms.ListView();
      this.columnField = new System.Windows.Forms.ColumnHeader();
      this.columnValue = new System.Windows.Forms.ColumnHeader();
      this.SuspendLayout();
      // 
      // listView1
      // 
      this.listView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
      this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
                                                                                this.columnField,
                                                                                this.columnValue});
      this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
      this.listView1.Location = new System.Drawing.Point(0, 0);
      this.listView1.Name = "listView1";
      this.listView1.Size = new System.Drawing.Size(314, 272);
      this.listView1.TabIndex = 0;
      this.listView1.View = System.Windows.Forms.View.Details;
      // 
      // columnField
      // 
      this.columnField.Text = "Field";
      this.columnField.Width = 100;
      // 
      // columnValue
      // 
      this.columnValue.Width = 200;
      // 
      // IdentifyDlg
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(314, 272);
      this.Controls.Add(this.listView1);
      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
      this.Name = "IdentifyDlg";
      this.ShowInTaskbar = false;
      this.Text = "Identify Dialog";
      this.ResumeLayout(false);

    }
		#endregion

    /// <summary>
    /// Populates the dialog's listview in order to display the identify results
    /// </summary>
    /// <param name="propSet"></param>
    /// <remarks>The identify results are passed by the layer by the IdentifyObject through a PropertySet</remarks>
    public void SetProperties(IPropertySet propSet)
    {
      if(null == propSet)
        return;

      //The listView gets pairs of items since it has two columns for fields and value
			
      string id = Convert.ToString(propSet.GetProperty("ID"));
      listView1.Items.Add(new ListViewItem(new string[2] {"ID", id}));

      string zipCode = Convert.ToString(propSet.GetProperty("ZIPCODE"));
      listView1.Items.Add(new ListViewItem(new string[2] {"ZIPCODE", zipCode}));

      string cityName = Convert.ToString(propSet.GetProperty("CITYNAME"));
      listView1.Items.Add(new ListViewItem(new string[2] {"CITYNAME", cityName}));

      string latitude = Convert.ToString(propSet.GetProperty("LAT"));
      listView1.Items.Add(new ListViewItem(new string[2] {"LATITUDE", latitude}));

      string longitude = Convert.ToString(propSet.GetProperty("LON"));
      listView1.Items.Add(new ListViewItem(new string[2] {"LONGITUDE", longitude}));

      string temperature = Convert.ToString(propSet.GetProperty("TEMPERATURE"));
      listView1.Items.Add(new ListViewItem(new string[2] {"TEMPERATURE", temperature}));

      string description = Convert.ToString(propSet.GetProperty("CONDITION"));
      listView1.Items.Add(new ListViewItem(new string[2] {"DESCRIPTION", description}));

      string day = Convert.ToString(propSet.GetProperty("DAY"));
      listView1.Items.Add(new ListViewItem(new string[2] {"DAY", day}));

      string date = Convert.ToString(propSet.GetProperty("DATE"));
      listView1.Items.Add(new ListViewItem(new string[2] {"DATE", date}));

      string low = Convert.ToString(propSet.GetProperty("LOW"));
      listView1.Items.Add(new ListViewItem(new string[2] {"LOW", low}));

      string high = Convert.ToString(propSet.GetProperty("HIGH"));
      listView1.Items.Add(new ListViewItem(new string[2] {"HIGH", high}));

      string updated = Convert.ToDateTime(propSet.GetProperty("UPDATED")).ToLongTimeString();
      listView1.Items.Add(new ListViewItem(new string[2] {"UPDATED", updated}));

      string icon = Convert.ToString(propSet.GetProperty("ICONNAME"));
      listView1.Items.Add(new ListViewItem(new string[2] {"ICON", icon}));
    }
	}
}

[Visual Basic .NET]

IdentifyDlg.vb

Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports ESRI.ArcGIS.esriSystem

  ''' <summary>
  ''' The IdentifyDlg is used by the Identify object to display the identify results
  ''' </summary>
	Public Class IdentifyDlg : Inherits System.Windows.Forms.Form
	Private listView1 As System.Windows.Forms.ListView
	Private columnField As System.Windows.Forms.ColumnHeader
	Private columnValue As System.Windows.Forms.ColumnHeader
		''' <summary>
		''' Required designer variable.
		''' </summary>
		Private components As System.ComponentModel.Container = Nothing

		Public Sub New()
			'
			' Required for Windows Form Designer support
			'
			InitializeComponent()

			'
			' TODO: Add any constructor code after InitializeComponent call
			'
		End Sub

		''' <summary>
		''' Clean up any resources being used.
		''' </summary>
		Protected Overrides Overloads Sub Dispose(ByVal disposing As Boolean)
			If disposing Then
				If Not components Is Nothing Then
					components.Dispose()
				End If
			End If
			MyBase.Dispose(disposing)
		End Sub

		#Region "Windows Form Designer generated code"
		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()
			Me.listView1 = New System.Windows.Forms.ListView
			Me.columnField = New System.Windows.Forms.ColumnHeader
			Me.columnValue = New System.Windows.Forms.ColumnHeader
			Me.SuspendLayout()
			'
			'listView1
			'
			Me.listView1.BorderStyle = System.Windows.Forms.BorderStyle.None
			Me.listView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.columnField, Me.columnValue})
			Me.listView1.Dock = System.Windows.Forms.DockStyle.Fill
			Me.listView1.Location = New System.Drawing.Point(0, 0)
			Me.listView1.Name = "listView1"
			Me.listView1.Size = New System.Drawing.Size(314, 272)
			Me.listView1.TabIndex = 0
			Me.listView1.UseCompatibleStateImageBehavior = False
			Me.listView1.View = System.Windows.Forms.View.Details
			'
			'columnField
			'
			Me.columnField.Text = "Field"
			Me.columnField.Width = 100
			'
			'columnValue
			'
			Me.columnValue.Width = 200
			'
			'IdentifyDlg
			'
			Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
			Me.ClientSize = New System.Drawing.Size(314, 272)
			Me.Controls.Add(Me.listView1)
			Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
			Me.Name = "IdentifyDlg"
			Me.ShowInTaskbar = False
			Me.Text = "Identify Dialog"
			Me.ResumeLayout(False)

		End Sub
		#End Region

	''' <summary>
	''' Populates the dialog's listview in order to display the identify results
	''' </summary>
	''' <param name="propSet"></param>
	''' <remarks>The identify results are passed by the layer by the IdentifyObject through a PropertySet</remarks>
	Public Sub SetProperties(ByVal propSet As IPropertySet)
	  If Nothing Is propSet Then
		Return
	  End If

        'The listView gets pairs of items since it has two columns for fields and value

	  Dim id As String = Convert.ToString(propSet.GetProperty("ID"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"ID", id}))

	  Dim zipCode As String = Convert.ToString(propSet.GetProperty("ZIPCODE"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"ZIPCODE", zipCode}))

	  Dim cityName As String = Convert.ToString(propSet.GetProperty("CITYNAME"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"CITYNAME", cityName}))

	  Dim latitude As String = Convert.ToString(propSet.GetProperty("LAT"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"LATITUDE", latitude}))

	  Dim longitude As String = Convert.ToString(propSet.GetProperty("LON"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"LONGITUDE", longitude}))

	  Dim temperature As String = Convert.ToString(propSet.GetProperty("TEMPERATURE"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"TEMPERATURE", temperature}))

	  Dim description As String = Convert.ToString(propSet.GetProperty("CONDITION"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"DESCRIPTION", description}))

	  Dim day As String = Convert.ToString(propSet.GetProperty("DAY"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"DAY", day}))

	  Dim [date] As String = Convert.ToString(propSet.GetProperty("DATE"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"DATE", [date]}))

	  Dim low As String = Convert.ToString(propSet.GetProperty("LOW"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"LOW", low}))

	  Dim high As String = Convert.ToString(propSet.GetProperty("HIGH"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"HIGH", high}))

	  Dim updated As String = Convert.ToDateTime(propSet.GetProperty("UPDATED")).ToLongTimeString()
	  listView1.Items.Add(New ListViewItem(New String(1) {"UPDATED", updated}))

	  Dim icon As String = Convert.ToString(propSet.GetProperty("ICONNAME"))
	  listView1.Items.Add(New ListViewItem(New String(1) {"ICON", icon}))
	End Sub
	End Class