[BUG] Search reset sometimes not working (#303), version 1.2.2.12

This commit is contained in:
Markus Hofknecht 2022-01-30 16:52:42 +01:00
parent 968cf08a36
commit 9e65ec3143
2 changed files with 12 additions and 6 deletions

View file

@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.2.11")] [assembly: AssemblyVersion("1.2.2.12")]
[assembly: AssemblyFileVersion("1.2.2.11")] [assembly: AssemblyFileVersion("1.2.2.12")]

View file

@ -779,10 +779,12 @@ namespace SystemTrayMenu.UserInterface
like = $"LIKE '%{searchString}%'"; like = $"LIKE '%{searchString}%'";
} }
bool isSearchStringEmpty = string.IsNullOrEmpty(searchString);
try try
{ {
if (Properties.Settings.Default.ShowOnlyAsSearchResult && if (Properties.Settings.Default.ShowOnlyAsSearchResult &&
string.IsNullOrEmpty(searchString)) isSearchStringEmpty)
{ {
data.DefaultView.RowFilter = "[SortIndex] LIKE '%0%'"; data.DefaultView.RowFilter = "[SortIndex] LIKE '%0%'";
} }
@ -805,8 +807,7 @@ namespace SystemTrayMenu.UserInterface
} }
string columnSortIndex = "SortIndex"; string columnSortIndex = "SortIndex";
if (isSearchStringEmpty)
if (string.IsNullOrEmpty(searchString))
{ {
foreach (DataRow row in data.Rows) foreach (DataRow row in data.Rows)
{ {
@ -852,7 +853,7 @@ namespace SystemTrayMenu.UserInterface
{ {
RowData rowData = (RowData)row.Cells[2].Value; RowData rowData = (RowData)row.Cells[2].Value;
if (!string.IsNullOrEmpty(searchString) || !rowData.ShowOnlyWhenSearch) if (!isSearchStringEmpty || !rowData.ShowOnlyWhenSearch)
{ {
rowData.RowIndex = row.Index; rowData.RowIndex = row.Index;
@ -880,6 +881,11 @@ namespace SystemTrayMenu.UserInterface
{ {
timerUpdateIcons.Start(); timerUpdateIcons.Start();
} }
if (isSearchStringEmpty)
{
dgv.FirstDisplayedScrollingRowIndex = 0;
}
} }
private void PictureBox_MouseEnter(object sender, EventArgs e) private void PictureBox_MouseEnter(object sender, EventArgs e)