Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 上下文提示列表的右定位(Intellisense)_C# - Fatal编程技术网

C# 上下文提示列表的右定位(Intellisense)

C# 上下文提示列表的右定位(Intellisense),c#,C#,就像这张来自阿瓦隆的图片: 如何正确定位上下文提示或智能感知 塞纳里奥: 我正在开发一个代码编辑器,我使用richtextbox(rtb)作为c编辑器,使用combobox(lb)作为上下文提示 除了combobox的正确定位(上下文提示)之外,所有代码几乎都完成了() 我使用以下代码: Point cursorPt = Cursor.Position; lb.Location = PointToClient(cursorPt); 但当鼠标光标移动时,它会出现。。。如果鼠标光标位于窗体外部,

就像这张来自阿瓦隆的图片:

如何正确定位上下文提示或智能感知

塞纳里奥:

我正在开发一个代码编辑器,我使用richtextbox(rtb)作为c编辑器,使用combobox(lb)作为上下文提示

除了combobox的正确定位(上下文提示)之外,所有代码几乎都完成了()

我使用以下代码:

Point cursorPt = Cursor.Position;
lb.Location = PointToClient(cursorPt);
但当鼠标光标移动时,它会出现。。。如果鼠标光标位于窗体外部,则它也不会出现

此外,代码如下:

 public void TextChangedEvent(object sender, EventArgs e)
    {
        lb.BringToFront();

        RichTextBox rtb = sender as RichTextBox;

        if (rtb != null)
        {
            //pass through to the HighlightType class
            HighlighType HighlighType = new HighlighType(rtb);
            lb.Visible = false;
            lb.Items.Clear();
        }

        // Calculate the starting position of the current line.
        int start = 0, end = 0;
        for (start = rtb.SelectionStart - 1; start > 0; start--)
        {
            if (rtb.Text[start] == '\n') { start++; break; }
        }

        // Calculate the end position of the current line.
        for (end = rtb.SelectionStart; end < rtb.Text.Length; end++)
        {
            if (rtb.Text[end] == '\n') break;
        }

        // Extract the current line that is being edited.
        String line = rtb.Text.Substring(start, end - start);

        // Backup the users current selection point.
        int selectionStart = rtb.SelectionStart;
        int selectionLength = rtb.SelectionLength;

        // Split the line into tokens.
        Regex r = new Regex("([ \\t{}();])");
        Regex singlequote = new Regex("\'[^\"]*\'");
        Regex doublequote = new Regex("\"[^\"]*\"");
        string[] tokens = r.Split(line);
        int index = start;
        foreach (string token in tokens)
        {
            // Set the token's default color and font.
            rtb.SelectionStart = index;
            rtb.SelectionLength = token.Length;
            rtb.SelectionColor = Color.Black;
            rtb.SelectionFont = new Font("Courier New", 10, FontStyle.Regular);


            if (token == "//" || token.StartsWith("//"))
            {
                // Find the start of the comment and then extract the whole comment.
                int length = line.Length - (index - start);
                string commentText = rtb.Text.Substring(index, length);
                rtb.SelectionStart = index;
                rtb.SelectionLength = length;
                HighlighType.commentsType(rtb);
                break;
            }

            //*** invention code:

            Point cursorPt = Cursor.Position;
            lb.Location = PointToClient(cursorPt);

            KeyWord keywordsL = new KeyWord();
            KeyWord eventsL = new KeyWord();

            if (token == "." || token.StartsWith(".") & token.EndsWith(" "))
            {
                foreach (string str in keywordsL.keywords)
                {
                    lb.Items.Add(str);
                    lb.Visible = true;
                    lb.Focus();

                }
public void TextChangedEvent(对象发送者,事件参数e)
{
lb.布林托夫隆();
RichTextBox rtb=发送方为RichTextBox;
如果(rtb!=null)
{
//传递到HighlightType类
HighlighType HighlighType=新的HighlighType(rtb);
lb.可见=假;
lb.Items.Clear();
}
//计算当前线路的起始位置。
int start=0,end=0;
对于(start=rtb.SelectionStart-1;start>0;start--)
{
如果(rtb.Text[start]='\n'){start++;break;}
}
//计算当前行的结束位置。
对于(end=rtb.SelectionStart;end
提前准备

Point point = this.rtb.GetPositionFromCharIndex(rtb.SelectionStart);
this.lb.Location = point;