Prerequisites
A session and a subscription with the server must be established.
Description
The following dialog shows an example dialog for deleting monitored items. Press the button “Show Code” to display the corresponding code, and the button “Help” to show this documentation page.
All currently monitored items are shown in the list at the bottom of the dialog window. Check the box in front of the items to be deleted and press the button “Delete”. Check the box in front of “Use Asynchronous Pattern” to call “BeginDelete” instead of “Delete”.
Sample Code
The following code deletes the specified monitored items.
try
{
Session session = m_parent.Session;
if (session == null)
{
return;
}
List<ListViewItem> items = new List<ListViewItem>();
List<MonitoredItem> monitoredItems = new List<MonitoredItem>();
foreach (ListViewItem item in MonitoredItemsLV.Items)
{
if (item.Checked)
{
MonitoredItem monitoredItem = (MonitoredItem)item.Tag;
monitoredItems.Add(monitoredItem);
items.Add(item);
}
}
List<StatusCode> results = m_subscription.DeleteMonitoredItems(
monitoredItems,
new RequestSettings() { OperationTimeout = 10000 });
for (int ii = 0; ii < results.Count; ii++)
{
{
items[ii].Remove();
continue;
}
UpdateItem((ListViewItem)monitoredItems[ii].UserData, monitoredItems[ii]);
}
foreach (ColumnHeader header in MonitoredItemsLV.Columns)
{
header.Width = -2;
}
}
catch (Exception exception)
{
ExceptionDlg.Show(this.Text, exception);
}
finally
{
Cursor = Cursors.Default;
}