EditAttributesDialog.CreatingEditGroups += new EventHandler<CreatingEditGroupsEventArgs>(EditAttributesPage_CreatingEditGroupsEvent);
private void EditAttributesPage_CreatingEditGroupsEvent(object sender, CreatingEditGroupsEventArgs e) { try { FeatureDataRow fdr = e.FeatureDataRow; foreach (DataColumn dc in fdr.FeatureLayer.Columns) { // Auto Populate the DATE Field if (dc.ColumnName.ToLower().IndexOf("date") != -1) { fdr[dc.ColumnName] = DateTime.Now; } } if (sender is EditAttributesDialog) { // Refresh the Edit Dialog: EditAttributesDialog editDialog = (EditAttributesDialog)sender; // Attempt to refresh layout and display auto populated // None of these worked: //editDialog.Refresh(); //editDialog.ResumeLayout(); //editDialog.Update(); //editDialog.Show(); //editDialog.Focus(); //editDialog.Activate(); //editDialog.CreateGraphics(); //editDialog.PerformAutoScale(); //editDialog.Hide(); //editDialog.Show(); //MobileApplication.Current.CurrentForm.Refresh(); //editDialog.On //editDialog.BringToFront(); } } catch (Exception ex) { ESRI.ArcGIS.Mobile.Client.Dialogs.MessageDialog.Show(ex.Message, "ERROR Edit Attributes", MessageBoxButtons.OK); } }
Yes I have also had the same problem. I figured out 2 ways to refresh or work arounds.
1) When transitioning to the AttributesForm page, just before you transition to the form, I have a procedure which will auto populate all the necessary fields. So when the user sees the attributes forms, all information will be filled in. So by doing this it is a work around, meaning auto populate your fields before transitioning to the attributes form.
Yes, you cannot refresh the AttributesForm right when you are on it with even code. Yes, you can refresh the AttributesForm by loading a new form and then going back to the AttributesForm, this works because it does reload the form, but is not a suitable solution.
2) The trick to refreshing is to use Height and Width of the page, I am using this for my WPF.Map control to refresh the map. All I do is simply Height - 1 and it refreshes the map. I am assuming this could work for the attributes form, but I am not 100%. I also believe you are using the Mobile app, whereas I am using the WPF app.
Regardless, I hope the Height property can be used for the page in your app which will refresh the attributes form. You will also need to use Height + 1 to fix the page back to normal height. If you don't you form will become smaller every time you transition to it (maybe).
void m_FeaturesChanged_Event(object sender, EditFeatureAttributesPageEventArgs e) { try { Feature feature = e.Page.Feature; FeatureDataRow fdr = feature.FeatureDataRow; foreach (DataColumn dc in fdr.FeatureLayer.Columns) { if (dc.ColumnName.ToLower().IndexOf("date") != -1) { fdr[dc.ColumnName] = DateTime.Now.ToString(); } } } catch (Exception ex) { // This happens, we just have to catch it so the application doesn't error out // A message box isn't necessary here since the user would ALWAYS see it. } }
/// <summary> /// Event fired when Edit Attributes Page is opened /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditAttributesPage_CreatingEditGroupsEvent(object sender, CreatingEditGroupsEventArgs e) { try { // Go through each column in the feature being edited FeatureDataRow fdr = e.FeatureDataRow; // Set the feature data row to a new value foreach (DataColumn dc in fdr.FeatureLayer.Columns) { // Auto Populate the DATE Field when a new feature is collected if (dc.ColumnName.ToLower().IndexOf("date") != -1) { fdr[dc.ColumnName] = DateTime.Now; } } // Now, set the default text value of the group to the same as above // This is done because a simple "refresh()" cannot be called (it doesn't work) for (int i = 0; i < e.Groups.Count; i++) { // Assume that there are two TextItems within each group by default // Check for this: if (e.Groups.Items.Count == 2) { // Check that the first and second Item are of type TextItem if (e.Groups.Items[0].GetType() == typeof(TextItem) && e.Groups.Items[1].GetType() == typeof(TextItem)) { // The item is now assumed a TextItem, so now cast it: TextItem itemHeader = (TextItem)e.Groups.Items[0]; // Check that the text value contains "date" if (itemHeader.Text.ToLower().IndexOf("date") != -1) { // Code to "refresh" the date attribute: // this is the date column, now auto populate it with today's date TextItem dateItem = (TextItem)e.Groups.Items[1]; dateItem.Text = DateTime.Now.ToString(); // Code to simply hide it only ever allowing the auto populate code to // add the information in: e.Groups.Items.Clear(); } } } } } catch (Exception ex) { ESRI.ArcGIS.Mobile.Client.Dialogs.MessageDialog.Show(ex.Message, "ERROR Edit Attributes", MessageBoxButtons.OK); } }