コード例 #1
0
        public void FindNext()
        {
            var start      = rbDown.Checked ? ++_last : --_last;
            var found      = false;
            var found_text = "";

            if (rbDown.Checked)
            {
                for (; _last < _text.Length; _last++)
                {
                    if (!find(_text[_last], out found_text))
                    {
                        continue;
                    }
                    found = true;
                    break;
                }

                if (!found)
                {
                    for (_last = 0; _last < start; _last++)
                    {
                        if (!find(_text[_last], out found_text))
                        {
                            continue;
                        }
                        found = true;
                        break;
                    }
                }
            }
            else
            {
                for (; _last > 0; _last--)
                {
                    if (!find(_text[_last], out found_text))
                    {
                        continue;
                    }
                    found = true;
                    break;
                }

                if (!found)
                {
                    for (_last = _text.Length - 1; _last > start; _last--)
                    {
                        if (!find(_text[_last], out found_text))
                        {
                            continue;
                        }
                        found = true;
                        break;
                    }
                }
            }
            if (!found)
            {
                MessageBox.Show(@"Text not found.");
                return;
            }

            if (!_found.ContainsKey(_last + 1))
            {
                grdResults.Rows.Add(_last + 1, _text[_last], found_text);
                _found.Add(_last + 1, _found.Count);
            }

            grdResults.Rows[_found[_last + 1]].Selected = true;
            grdResults.CurrentCell = grdResults.Rows[_found[_last + 1]].Cells[0];

            FoundText?.Invoke(this, new FoundTextEventHandlerArgs(txtSearch.Text, _last));
        }
コード例 #2
0
 private void grdResults_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     FoundText?.Invoke(this, new FoundTextEventHandlerArgs(txtSearch.Text, Convert.ToInt32(grdResults.SelectedRows[0].Cells[0].Value) - 1));
 }