• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 124,  comments - 29,  trackbacks - 0
            大小寫匹配向上搜索的功能作為參數傳進去

            類里面的成員變量有:
                    private TextBox tb;
                    private int findCount = 0;
                    private int curFindIndex = 0;   //為替換做準備
                    private int curFindLength = 0; //為替換做準備
                    private string findContext;
                    private string searchText;
             1  private void FindText(TextBox tb, String findContext, ref int findCount, int CurIndex, bool ingnoreCase, bool IsUp)
             2        {
             3            if (IsUp)
             4            {
             5                String LeftText = tb.Text.Substring(CurIndex);
             6                int searchLength = tb.Text.Length - LeftText.Length - tb.SelectionLength;
             7                searchText = tb.Text.Substring(0, searchLength);
             8            }

             9            else
            10            {
            11                searchText = tb.Text.Substring(CurIndex);
            12            }

            13
            14            if (ingnoreCase)
            15            {
            16                searchText = searchText.ToUpper();
            17                findContext = findContext.ToUpper();
            18            }

            19            int index = 0;
            20            if (IsUp)
            21            {
            22                index = searchText.LastIndexOf(findContext);
            23            }

            24            else
            25            {
            26                index = searchText.IndexOf(findContext);
            27            }

            28
            29            if (index != -1)
            30            {
            31                findCount += 1;
            32                if(IsUp)
            33                {
            34                    tb.SelectionStart = index;
            35                }

            36                else
            37                {
            38                    tb.SelectionStart = index + CurIndex;
            39                }

            40                
            41                tb.SelectionLength = findContext.Length;
            42                tb.Focus();
            43                curFindIndex = tb.SelectionStart;
            44                curFindLength = tb.SelectionLength;
            45            }

            46            else
            47            {
            48                if (findCount == 0)
            49                {
            50                    MessageBox.Show("未找到以下指示文本""濟南網通");
            51                }

            52                else
            53                {
            54                    MessageBox.Show("查找到了盡頭""濟南網通");
            55                }

            56            }

            57        }

            1  private void btnFind_Click(object sender, EventArgs e)
            2        {
            3            bool IsUp = this.cbUp.Checked;
            4            bool IgnoreCase = !this.cbBig.Checked;
            5            FindText(tb, txtFind.Text, ref findCount, tb.SelectionStart + tb.SelectionLength, IgnoreCase,IsUp);
            6               
            7        }

            8

             1
             2        private void btnReplace_Click(object sender, EventArgs e)
             3        {
             4            if (curFindLength > 0)
             5            {
             6                string strTmp = tb.Text.Remove(curFindIndex, curFindLength);
             7                tb.Text = strTmp.Insert(curFindIndex, txtReplace.Text);
             8                curFindLength = 0;
             9            }

            10        }

             1        private void btnReplaceAll_Click(object sender, EventArgs e)
             2        {
             3            if (cbBig.Checked)
             4            {
             5                tb.Text = tb.Text.Replace(txtFind.Text, txtReplace.Text);
             6            }

             7            else
             8            {
             9                string str1 = txtFind.Text.ToLower();
            10                string str2 = txtFind.Text.ToUpper();
            11                tb.Text = tb.Text.Replace(str1, txtReplace.Text);
            12                tb.Text = tb.Text.Replace(str2, txtReplace.Text);
            13            }

            14               
            15        }

             

             

             1        private void txtFind_TextChanged(object sender, EventArgs e)
             2        {
             3            findContext = txtFind.Text;
             4            if (findContext != null && findContext.Length > 0)
             5            {
             6                btnFind.Enabled = true;
             7                btnReplace.Enabled = true;
             8                btnReplaceAll.Enabled = true;
             9            }

            10            else
            11            {
            12                btnFind.Enabled = false;
            13                btnReplace.Enabled = false;
            14                btnReplaceAll.Enabled = false;
            15            }

            16        }


             

            posted on 2008-09-19 10:35 天書 閱讀(1315) 評論(0)  編輯 收藏 引用

            <2008年9月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            常用鏈接

            留言簿(5)

            隨筆檔案

            文章分類

            文章檔案

            好友的Bolg

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲精品97久久中文字幕无码| 久久国产成人| 国产高潮国产高潮久久久| 99久久国产综合精品麻豆| 久久国产精品视频| 久久成人小视频| 国产精品99久久久久久人| 久久久艹| 国产综合久久久久久鬼色| 久久精品国产色蜜蜜麻豆| 亚洲第一永久AV网站久久精品男人的天堂AV| 久久天天日天天操综合伊人av| 日产精品久久久一区二区| 久久久精品视频免费观看| 亚洲国产精品久久66| 久久A级毛片免费观看| 亚洲欧美另类日本久久国产真实乱对白| 无码日韩人妻精品久久蜜桃 | 久久超碰97人人做人人爱| 久久精品国产亚洲αv忘忧草| 狠狠色婷婷久久一区二区三区 | 精品久久久久久无码中文野结衣| 久久亚洲日韩看片无码| 久久国产免费| 久久久久国产精品| 国产精品9999久久久久| 久久夜色精品国产噜噜噜亚洲AV| 久久久综合香蕉尹人综合网| 精品国际久久久久999波多野| 国产亚洲精久久久久久无码77777 国产亚洲精品久久久久秋霞 | 久久精品99无色码中文字幕| 久久精品国产亚洲Aⅴ香蕉| 国内精品久久久久伊人av| 国色天香久久久久久久小说 | 97久久精品午夜一区二区| 亚洲日本va中文字幕久久| 久久婷婷五月综合成人D啪 | 久久人人爽人人爽人人片AV麻烦| 亚洲国产精品成人AV无码久久综合影院| 国产91久久精品一区二区| 久久国产免费观看精品|