Archive for Settembre 18th, 2007

Get the Data Record from mouse click on a XtraTreeList

Settembre 18th, 2007

Description: data-record xtratreelist mouse-click

Link: http://www.codekeep.net/snippets/e82e27f7-2011-4f36-a0c7-120e030b6da6.aspx

 TreeListHitInfo hi = TreeList.CalcHitInfo(e.Location);
 if (hi.Node != null)
 {
     StreamChainConfig config = TreeList.GetDataRecordByNode(hi.Node) as StreamChainConfig;
 }

Create a simple table in ArcObjects

Settembre 18th, 2007

Description: Sample for creating a table with two attributes.

Link: http://www.codekeep.net/snippets/668235c3-789d-4ec3-8d54-a42ee53f5f01.aspx

private static ITable CreateBorderElementWorkListTable(IWorkspace workspace)
{
    try
    {
        IFieldEdit fieldeditOid = (IFieldEdit) new FieldClass();
        fieldeditOid.Type_2 = esriFieldType.esriFieldTypeOID;
        fieldeditOid.Name_2 = "OID";

        IFieldEdit fieldeditGuid = (IFieldEdit) new FieldClass();
        fieldeditGuid.Type_2 = esriFieldType.esriFieldTypeGUID;
        fieldeditGuid.Name_2 = "GUID";

        IFields fields = new FieldsClass();
        IFieldsEdit fieldsEdit = (IFieldsEdit) fields;
        fieldsEdit.FieldCount_2 = 2;

        fieldsEdit.set_Field(0, fieldeditOid);
        fieldsEdit.set_Field(1, fieldeditGuid);

        IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
        IObjectClassDescription ocDesc = (IObjectClassDescription) fcDesc;
        IFeatureWorkspace fw = (IFeatureWorkspace) workspace;
        ITable table = fw.CreateTable(
            "BorderElementWorkList", fields, ocDesc.InstanceCLSID, ocDesc.ClassExtensionCLSID, "");
        return table;
    }
    catch (Exception ex)
    {
        _msg.Error(ex);
        return null;
    }
}