DataView 的 RowFilter 沒有 distinct 功能,所以實作此功能,將 distinct DataView 的結果存入 ArrayList。

  //Get Distinct Data from DataView
  private ArrayList GetDistinctData(ref DataView dv, ref ArrayList al, string column_name)
  {
   bool existed = false;

   foreach (DataRowView dr in dv)
   {
    existed = false;

    for (int i = 0; i < al.Count; i++)
    {
     if (dr[column_name].ToString() == al[i].ToString())
     {
      existed = true;
     }
    }

    if (existed == false)
    {
     al.Add(dr[column_name]);
    }
   }

   return al;
  }