Esempio n. 1
0
        private void BtnSearchNext_Click(object sender, EventArgs e)
        {
            if (CmbSearch.Text.Length == 0)
            {
                _ = CmbSearch.Focus();
                return;
            }

            _ = RtbResult.Focus();
            CmbSearch.SelectionStart = 0;

            // 行毎に検索!!
            // 検索位置にカーソル移動
            while (Regex.IsMatch(RtbResult.Text, CmbSearch.Text, RegexOptions.IgnoreCase))
            {
                int iLineBgnPos = 0;

                foreach (string _s1 in RtbResult.Text.Split('\n'))
                {
                    // 無駄なループを減らすため、こまめに GblResult_CursorPos の位置をチェック
                    if (iLineBgnPos + _s1.Length > GblResult_CursorPos)
                    {
                        foreach (Match _m1 in Regex.Matches(_s1, CmbSearch.Text, RegexOptions.IgnoreCase))
                        {
                            if (iLineBgnPos + _m1.Index >= GblResult_CursorPos)
                            {
                                _ = RtbResult.Focus();
                                RtbResult.Select(iLineBgnPos + _m1.Index, _m1.Value.Length);
                                GblResult_CursorPos = iLineBgnPos + _m1.Index + _m1.Value.Length;
                                return;
                            }
                        }
                    }
                    iLineBgnPos += _s1.Length + 1;
                }

                GblResult_CursorPos = 0;
            }
        }
Esempio n. 2
0
 private void CmsResult_Opened(object sender, EventArgs e)
 {
     _ = RtbResult.Focus();
 }