Exemplo n.º 1
0
        /// <summary>
        /// For applying custom sort on DataTable
        /// </summary>
        /// <param name="columnName">name of the sort column</param>
        /// <param name="comparer">the comparer which is appropriate for comparing the content of the column</param>
        public void ApplySort(string columnName, BaseCustomComparer comparer)
        {
            var rows = new List <ExtendedDataRow>();

            foreach (DataRow row in this.Rows)
            {
                ExtendedDataRow newRow = this.GetNewRow();
                newRow.Clone((row as ExtendedDataRow));
                rows.Add(newRow);
            }
            rows.Sort((row1, row2) =>
            {
                return(comparer.Compare(row1[columnName], row2[columnName]));
            });
            for (int i = 0; i < Rows.Count; i++)
            {
                (this.Rows[i] as ExtendedDataRow).Clone(rows[i]);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Clone the values of other ExtendedDataRow on current ExtendedDataRow
 /// </summary>
 /// <param name="extendedDataRow">the other ExtendedDataRow</param>
 public void Clone(ExtendedDataRow extendedDataRow)
 {
     this.ItemArray     = extendedDataRow.ItemArray;
     this.IsHighlighted = extendedDataRow.IsHighlighted;
 }