Within the code I gather all of the information and using that data I convert it to a datatable which I then use as the source for my datagridview.
When this data is loaded I have an existing counter that works based off of the $datagridview.rows.count.
I have filters in place that the user can use filter by City, Region, Country, or Postal and the row count updates accordingly.
What I am trying to do, however, is to show the unique counts of City, Region, and Country based on the filtering and filtered data.
Does anyone have any suggestions on how to accomplish this? The below is a snippit of the code I use when filtering, and where I need to have the counts come from after the data is loaded. Maybe I need do that differently, or somehow calculate the information differently.
Code: Select all
$tbx_IPL_FilterCity_TextChanged = {
[string]$CityFilter = "`'%{0}%`'" -f $tbx_IPL_FilterCity.Text
$filter = "City Like $CityFilter"
if ($tbx_IPL_FilterCity.text -eq "")
{
$ipInfoTable.defaultview.rowfilter = $null
$tbx_IPL_Count.Text = ($dgv_IPL_IPInformation.Rows.Count)
}
else
{
$ipInfoTable.defaultview.rowfilter = $filter
$tbx_IPL_Count.Text = ($dgv_IPL_IPInformation.Rows.Count)
}
}
Code: Select all
$tbx_IPL_CityCount.Text = ($dgv_IPL_IPInformation | Sort City -Unique).Count
$tbx_IPL_RegionCount.Text = ($dgv_IPL_IPInformation | Sort Region -Unique).Count
$tbx_IPL_CountryCount.Text = ($dgv_IPL_IPInformation | Sort Country -Unique).Count