Exemple #1
0
        private void Find(bool withUI)
        {
            // If the user has changed the selection since the last search,
            // Set the starting row at the row after the current first selection,
            // or at 0 if no selection of the last line is selected
            if (_userChangedSelection)
            {
                _findSettings.SearchStartingRow = 0;
                int row = 0;
                while (row < productList.Items.Count)
                {
                    if (productList.Items[row].Selected)
                    {
                        _findSettings.SearchStartingRow = row + 1;
                        break;
                    }
                    row++;
                }
                _userChangedSelection = false;
            }

            if (withUI)
            {
                FindProductForm dlg = new FindProductForm(_findSettings);
                dlg.Settings = _findSettings;
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    _findSettings = dlg.Settings;
                    // If nothing was found, reset search next time.
                    // If something was found, ignore selection changes made by finding.
                    bool result = Search.FindInProductList(productList, _findSettings);
                    _userChangedSelection = !result;
                    if (!result)
                    {
                        productList.EnsureVisible(0);
                    }
                    findAgainToolStripMenuItem.Enabled = true;
                }
            }
            else
            {
                if (_findSettings.IsValid)
                {
                    bool result = Search.FindInProductList(productList, _findSettings);
                    _userChangedSelection = !result;
                    if (!result)
                    {
                        productList.EnsureVisible(0);
                    }
                }
            }
        }
Exemple #2
0
        private void Find(bool withUI)
        {
            // If the user has changed the selection since the last search,
            // Set the starting row at the row after the current first selection,
            // or at 0 if no selection of the last line is selected
            if (_userChangedSelection)
            {
                _findSettings.SearchStartingRow = 0;
                int row = 0;
                while (row < productList.Items.Count)
                {
                    if (productList.Items[row].Selected)
                    {
                        _findSettings.SearchStartingRow = row + 1;
                        break;
                    }
                    row++;
                }
                _userChangedSelection = false;
            }

            if (withUI)
            {
                FindProductForm dlg = new FindProductForm(_findSettings);
                dlg.Settings = _findSettings;
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    _findSettings = dlg.Settings;
                    // If nothing was found, reset search next time.
                    // If something was found, ignore selection changes made by finding.
                    bool result = Search.FindInProductList(productList, _findSettings);
                    _userChangedSelection = !result;
                    if (!result) productList.EnsureVisible(0);
                    findAgainToolStripMenuItem.Enabled = true;
                }
            }
            else
            {
                if (_findSettings.IsValid)
                {
                    bool result = Search.FindInProductList(productList, _findSettings);
                    _userChangedSelection = !result;
                    if (!result) productList.EnsureVisible(0);
                }
            }
        }