How do you obtian the domain values to populate a drop-down combo box?

3968
4
Jump to solution
04-12-2011 08:01 AM
GenaroGarcia
New Contributor III
I'm creating a task to query a feature class layer that uses an address.
I'm need to populate a drop-down combo box with the streets name domain values.
Once I have all the information required, it selected the address point using the query and zooms in.

I've done this in 9.3.1 Mobile, but in Mobile 10 I'm having problems.
Any help is appreciated.
0 Kudos
1 Solution

Accepted Solutions
CiprianLazar
New Contributor III
I hope this piece of code will help you get started:

FeatureLayer featureLayer = (FeatureLayer)mobileCache1.Layers["Streets"];
DataTable dt = (DataTable)featureLayer.GetDomain(0,"street_name");
comboBox1.ValueMember = "Code"; //** Column name is case sensitive
comboBox1.DisplayMember = "Value";
comboBox1.DataSource = dt;

View solution in original post

4 Replies
CiprianLazar
New Contributor III
I hope this piece of code will help you get started:

FeatureLayer featureLayer = (FeatureLayer)mobileCache1.Layers["Streets"];
DataTable dt = (DataTable)featureLayer.GetDomain(0,"street_name");
comboBox1.ValueMember = "Code"; //** Column name is case sensitive
comboBox1.DisplayMember = "Value";
comboBox1.DataSource = dt;
by Anonymous User
Not applicable
Original User: Genaro Garcia

Thanks Ciprian....

That was exactly what I needed.
0 Kudos
YinghongLi
Occasional Contributor
I hope this piece of code will help you get started:

FeatureLayer featureLayer = (FeatureLayer)mobileCache1.Layers["Streets"];
DataTable dt = (DataTable)featureLayer.GetDomain(0,"street_name");
comboBox1.ValueMember = "Code"; //** Column name is case sensitive
comboBox1.DisplayMember = "Value";
comboBox1.DataSource = dt;


Hello,

I'd like to know how to find if the domain is a coded value domain or ranged domain.  here is my code:


FeatureDataRow fdr = _feature.FeatureDataRow;
                 int i = 0;
                 int d = 0;
                 foreach (DataColumn dc in fdr.FeatureSource.Columns)
                 {
                     //WriteToFile("column name=="+dc.ColumnName.ToUpper(), _errorLog, 2);
                     // find the userid field, and populate current userID to this field
                     //MessageBox.Show("columnname==" + dc.ColumnName.ToUpper());
                     IDomain domain = fdr.GetDomain(i);
                     if (domain != null)
                     {

                         CodedValueDomain cvd = (CodedValueDomain)domain;

                         if (cvd != null)
                         {
                             DataTable dtDomain = (DataTable)fdr.GetDomain(i);
                             d++;
                             if (d == 1)
                             {
                                 string stemp = "";
                                 for (int j = 0; j < dtDomain.Rows.Count; j++)
                                 {

                                     DataRow datarow = dtDomain.Rows;
                                     stemp = stemp + " code==" + datarow["Code"] + " value==" + datarow["Value"];


                                 }
                                 MessageBox.Show(stemp, "domain value");

                             }

                         }
                     }

Thanks.
0 Kudos
by Anonymous User
Not applicable
Original User: ciprianster

You shoud verify the type of that IDomain like this:
IDomain domain = fdr.GetDomain(i);
DataTable dtDomain = (DataTable)domain;
if (domain is CodedValueDomain)
{
      CodedValueDomain cvd = (CodedValueDomain)domain;
      //..................... Actions for CodedValueDomain
}
else // if (domain is RangeValueDomain)
{
      RangeValueDomain rvd = (RangeValueDomain)domain;
      //.................. Actions for RangeValueDomain
}
0 Kudos