ClearSelection Method

Overview

The ClearSelection method clears the selection state for all rows in a table by setting the value of the Selected to false for every row.

This helper is intended for UI-oriented scenarios where a table is used as a selectable list (for example, when your application allows multi-row selection and you want to clear all selections in one operation).

Declaration

/// <summary>
/// Clears selection for all rows in the table (delegates to inner table)
/// </summary>
/// <param name="observableDataTable">Observable data table</param>
public static void ClearSelection(this IObservableDataTable? dataTable)

Namespace and Assembly

Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll

Behavior

Usage Example

// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();

// 2. Create Department observable table with rows in different states
IObservableDataTable departmentObservableDataTable = observableDataSet.AddNewTable("Department");
departmentObservableDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentObservableDataTable.AddColumn("Name", DataTypeNames.STRING);

// Row in Added state
IObservableDataRow departmentObservableDataRow1 = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow1["Id"] = 1;
departmentObservableDataRow1["Name"] = "Reception";

// Row in Deleted state
IObservableDataRow departmentObservableDataRow2 = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow2["Id"] = 2;
departmentObservableDataRow2["Name"] = "Emergency";
departmentObservableDataRow2.AcceptChanges();
departmentObservableDataRow2.Selected = true;
departmentObservableDataRow2.Delete();

// Row in Modified state
IObservableDataRow departmentObservableDataRow3 = departmentObservableDataTable.AddNewRow();
departmentObservableDataRow3["Id"] = 3;
departmentObservableDataRow3["Name"] = "Emergency";
departmentObservableDataRow3.AcceptChanges();
departmentObservableDataRow3.Selected = true;
departmentObservableDataRow3["Name"] = "Finance";

// 3. Clear selection for all rows in the table
departmentObservableDataTable.ClearSelection();

Notes

 

Table of Content POCO DataSet Observable Data Table Members

 


Business Process Programming in .Net
© 2004–2026 Laskarzhevsky Software Inc.
Unless otherwise noted, the content of this website is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
Code examples are provided under the MIT License.
You are free to share and adapt the material provided that appropriate credit is given and any modifications are clearly indicated.
The information provided on this website is for educational purposes only.
The author and publisher make no warranties regarding the completeness or suitability of the information and are not responsible for any damages resulting from its use.