Select to view content in your preferred language

Refresh Attribute

626
4
07-09-2010 09:01 AM
JeffGiesler
Deactivated User
Hello Everyone,
I have a program that connect line ends update the attribute table that goes with it. If the attribute table is open when the program is run the table doesn't update visually. If i close and reopen or switch between seleted and all the attribute table shows the updates. Does anyone know how to update the attribute table without doing the above. I have tried ItableWindow2 (using Ilayer) but I might just be something wrong (the remove and relaod cache is crashing). I am writing in C# so any answers would be great in C# but I can read VB if necessary.
Thanks in advance.
Jeff
0 Kudos
4 Replies
AlagappanAL
Deactivated User
Hi,

If the table is read from ArcMap TOC to update the attributes and it is also in start editing mode, then the updated attributes (via code) will be refreshed automatically in attribute table without closing and opening it.

Could you please post your code so that it is easy to figure out the solution.


Regards
Alagappan
0 Kudos
JeffGiesler
Deactivated User
Alagappan,
I am not updating the rows in an edit session.  I don't need the user to be able to undo the changes.  Everything stores correctly the problem only occurs when the attribute table is left open.  I either want to close the attribute table or have it refresh after the program runs.  I am not sure what code you want to but I have attached the table window code I tried.  Any suggestions would be great.
Jeff
if (layer.Name.StartsWith("Pipeline"))
{
try
{
IDataset layerset = (IDataset)layer;
IWorkspace FCwrkSpc = layerset.Workspace;
string path = FCwrkSpc.PathName.ToString();
Commands.
SelectionCmds mycommand = new SelectionCmds();
mycommand.SelectKeyID(FCwrkSpc, layerset, layer,
"PIPELINE_UTILITY");
IFeatureLayer fLayer = (IFeatureLayer)layer;
//ITableWindow2 iptblwin = new TableWindowClass();
//iptblwin.FindViaLayer(layer);
//iptblwin.Layer = layer;
//iptblwin.Application = esriApp;
//iptblwin.PutPosition(50,50,100,50);
//iptblwin.TableControl.RemoveAndReloadCache();
//iptblwin.Refresh();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " " + "Please check you Pipeline Utility layer.");
}
}
0 Kudos
AlagappanAL
Deactivated User
Hi Jeff,

             Could you please try out the below code that works for me which updates a attribute of a featureclass and the updation is visible even when the attribute table is opened without refreshing/closing&reopening.

      Dim pMxdoc As IMxDocument = m_application.Document
            Dim pMap As IMap = pMxdoc.FocusMap
            Dim pLayer As ILayer = pMap.Layer(0)
            Dim pFL As IFeatureLayer = CType(pLayer, IFeatureLayer)
            Dim pFC As IFeatureClass = pFL.FeatureClass
            Dim pDataset As IDataset = CType(pFC, IDataset)
            Dim pWS As IWorkspace = pDataset.Workspace
            Dim pWSEdit As IWorkspaceEdit = CType(pWS, IWorkspaceEdit)
            pWSEdit.StartEditing(False)
            pWSEdit.StartEditOperation()
            Dim pfeature As IFeature = pFC.CreateFeature
            'make sure about the correct datatype of fields
            pfeature.Value(1) = "abc"
            pfeature.value(2) = "def"
            pfeature.Store()
            pWSEdit.StopEditOperation()
            pWSEdit.StopEditing(True)


Regards
Alagappan
0 Kudos
JeffGiesler
Deactivated User
Alagappan,
The code does show the records updating in the in the attribute table and updates my new features (so your code works) When I close my attribute table and then reopen it the original records that I am using to create the new features don't save any field changes that may happen to them.  If I turn off the edit session everything works fine except the attribute table update.
Cheers,
Jeff
0 Kudos