Irfan Song

Irfan Song

  • NA
  • 1
  • 0

Populating a Combobox for ARCGIS

Mar 5 2007 3:09 AM
Hello all
I am creating a userform for ARCMap, the form comprises of four comboboxes and a joint fuction.
In 1st combox the featurelayer is to e populated, in the second combobox the fieldnames associated with the featurelayer would be associated, in third combobox all thetables would be populated, and in the fourth box the fields associated with 3rd box is to be populated. I have got the 1st one and have difficulty in the three boxes. Could anybody help me out in this context.

The code runs like
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;
using System.Data.OleDb;
using System.Data.Common;
 
 
namespace Create_Forms
{
    public partial class BogsCal : Form
    {
        IMxDocument m_mxdoc;
        IMap myMap;
        
        string boglayer;
        string bogfield;
        string tablename;
        string tablefield;
 
        public BogsCal(IMxDocument myDoc)
        {
            InitializeComponent();
            m_mxdoc = myDoc;
            popComboBox(m_mxdoc.FocusMap);
            myMap = m_mxdoc.FocusMap;
            
        }
       
        
                 public ILayer findLayer(IMap map, string bog)
        {
           for (int i = 0; i <= map.LayerCount; i++)
            {
                if (map.get_Layer(i).Name == bog)
                {
                    return map.get_Layer(i);
                }
 
            }
            
            return null;
 
        }
       public ITable findTable(ITable map, string Table)
       {
            IStandaloneTableCollection standalonetablecoll =
            (IStandaloneTableCollection)myMap;
            for (int i = 0; i < standalonetablecoll.StandaloneTableCount; i++)
            {
               string tablename = standalonetablecoll.get_StandaloneTable(i).ToString();
               if (tablename == Table)
                {
                    IStandaloneTable sttable =
                        standalonetablecoll.get_StandaloneTable(i);
                   return sttable.Table;
               }
           }
           return null;
        }
        public void popComboBox(IMap map)
        {
            for (int i = 0; i < map.LayerCount; i++)
            {
                          string layername = map.get_Layer(i).Name.ToString();
                          cbo1.Items.Add(layername);
               
               //cbo1.Items.Add(adds the featurelayers) 
            }
            
        }
 
        private void button1_click(object sender, EventArgs e)
        {
        }
        private void combobox4_selectedIndesChanged(object sender, EventArgs e)
        {
        }
 
        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
 
        


}






   private void cbo1_SelectedIndexChanged(object sender, EventArgs e)
        {
 
        }
 
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
   }
        private void BogsCal_Load(object sender, EventArgs e)
        {
            //cbo1.Items.Add("map");
            boglayer  = cbo1.SelectedItem.ToString();
            ILayer myLayer = findLayer(myMap, boglayer   );
            IFeatureLayer myBogFeatLayer = (IFeatureLayer)myLayer;
            IFeatureClass myBogFeatureClass = myBogFeatLayer.FeatureClass;
 
            
        }
 
        }
}