如何以相反的顺序查找和选择 [英] How to find and select in reverse order

查看:95
本文介绍了如何以相反的顺序查找和选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在前方位置找到并选择单词,即(从上到下)

如果我点击向下单选按钮说rbDown以下代码可以运行fin



I can find and select the word in forward position i.e(Top to bottom)
If I click Down Radio button say rbDown the following code works fin

TextValue = findTextBox.Text;
               



                wordToReplace = replaceTextBox.Text;
                TextValue = findTextBox.Text;
                
                {

                    int startIndex = Program.MainForm.txtWritingBox.SelectionStart + Program.MainForm.txtWritingBox.SelectedText.Length;

                     string AfterCursor = Program.MainForm.txtWritingBox.Text.Substring(startIndex, Program.MainForm.txtWritingBox.Text.Length - startIndex);

                     if (AfterCursor.Contains(TextValue))
                     {
                         Program.MainForm.txtWritingBox.Select(startIndex + AfterCursor.IndexOf(TextValue), TextValue.Length);
                        

                     }
                     Program.MainForm.Focus();
                   
                }







如果我点击Up Radio Button说rbUp。

搜索应该从下到上进行。



如何做到这一点。



我想要代码




If I click Up Radio Button say rbUp.
The search should happen from bottom to top.

How to do this .

I want the code

推荐答案

看看 string.LastIndexOf [ ^ ] - 它的作用与string.IndexOf相同,但是从结尾开始,而不是从开始。
Look at string.LastIndexOf[^] - it works the same as string.IndexOf but from the end, rather than the beginning.


这篇关于如何以相反的顺序查找和选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆