winform:在richbox中光标在屏幕中的位置

实现vs中关键词link的效果,输入相关字符时能在浮窗上联想出相关词
winform:在richbox中光标在屏幕中的位置

img


img

我用 TextBox做了一个测试:

img


代码:

var source = new AutoCompleteStringCollection();
    source.AddRange(new string[]
                    {
                        "January",
                        "February",
                        "March",
                        "April",
                        "May",
                        "June",
                        "July",
                        "August",
                        "September",
                        "October",
                        "November",
                        "December"
                    });

    // Create and initialize the text box.
    var textBox = new TextBox
                  {
                      AutoCompleteCustomSource = source,
                      AutoCompleteMode = 
                          AutoCompleteMode.SuggestAppend,
                      AutoCompleteSource =
                          AutoCompleteSource.CustomSource,
                      Location = new Point(20, 20),
                      Width = ClientRectangle.Width - 40,
                      Visible = true,
                      ContextMenuStrip = ContextMenuStrip1  // bind your ContextMenuStrip here
                  };

    // Add the text box to the form.
    Controls.Add(textBox);

来自于文档:


希望对你有帮助。

如果你希望Visual Studio 能够拥有一个新功能, 请在以下论坛中提出你的建议:


对于第二张图片中的异常,你只需要在后面添加 ToString()方法即可。
如果你的问题与上面都无关,请提供更详细的问题描述。