2

您如何使用书签并浏览它们而不迷失在索引中?!

这是书签代码片段:

private void btnBM(object sender, EventArgs e)
    {
        Line currentLine = scintilla1.Lines.Current;
        if (scintilla1.Markers.GetMarkerMask(currentLine) == 0)
        {
            currentLine.AddMarker(0);
        }
        else
        {
            currentLine.DeleteMarker(0);
        }
    }

我想清除上一个指标并在下一个书签上放置一个指标,同时向下滚动以关注我尝试的下一个:

      scintilla1.Indicators[2].Search(scintilla1.GetRange(),scintilla1.GetRange(scintilla1.CurrentPos)).ClearIndicator(2);
        Range R;
            R = scintilla1.Markers.FindPreviousMarker().Range;   <-- Causes crashes bcoz of index 
                  scintilla1.Indicators[2].Style = IndicatorStyle.Box;
                  scintilla1.Indicators[2].Color = Color.DarkGoldenrod;
                  R.SetIndicator(2);
4

1 回答 1

0

我是这样做的,代码如下:

   private void button20_Click_1(object sender, EventArgs e)
    {
        scintilla1.GetRange().ClearIndicator(2);
        scintilla1.Indicators[2].Style = IndicatorStyle.Box;
        scintilla1.Indicators[2].Color = Color.Cyan;
        try
        {
            Line next = scintilla1.Markers.FindNextMarker(); //replace with previous to get the previous on the control bookmark

            scintilla1.Caret.Position = next.EndPosition;
            next.Range.SetIndicator(2);
            scintilla1.Caret.Goto(next.EndPosition);
            scintilla1.Focus();        
        }
        catch (Exception ex)
        {
            MessageBox.Show("No more marks.. " + ex.Message);
        }
    }
于 2013-02-05T22:32:18.483 回答