Articles in this section
Category / Section

How to accomplish multiple levels of context choice list implementation in the WinForms SyntaxEditor (EditControl)?

Multiple levels of context choice

Multiple levels of context choice list can be implemented by handling the ContextChoiceBeforeOpen and ContextChoiceOpen event.

C#

private void editControl1_ContextChoiceBeforeOpen(object sender, System.ComponentModel.CancelEventArgs e)
{
    ILexem lex;
    lex = this.editControl1.ContextChoiceController.LexemBeforeDropper as ILexem;
    if ((lex.Text == "this") || (lex.Text == "me"))
       firstLevel = true;
    else if (ContextChoiceListPresenceCheck(contextChoiceListLevelOne, lex.Text) == true)
       secondLevel = true;
    else
       e.Cancel = true;
}
private void editControl1_ContextChoiceOpen(Syncfusion.Windows.Forms.Edit.Interfaces.IContextChoiceController controller)
{
    if (firstLevel == true)
    {
       controller.Items.Clear();
       for (int i=0; i<contextChoiceListLevelOne.Length; i++)
       {
          controller.Items.Add(contextChoiceListLevelOne[i], "This is a" + contextChoiceListLevelOne[i], this.editControl1.ContextChoiceController.Images[i]);
       } 
    }
    else if (secondLevel == true)
    {
          controller.Items.Clear();
          for (int i=0; i<contextChoiceListLevelOne.Length; i++)
          {
              controller.Items.Add(contextChoiceListLevelTwo[i], "This is a" + contextChoiceListLevelTwo[i], this.editControl1.ContextChoiceController.Images[i]);
          } 
    }
    firstLevel = false;
    secondLevel = false;
}

 

VB

Private Sub editControl1_ContextChoiceBeforeOpen(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles editControl1.ContextChoiceBeforeOpen
    Dim lex As ILexem
    lex = CType(IIf(TypeOf Me.editControl1.ContextChoiceController.LexemBeforeDropper Is ILexem,       Me.editControl1.ContextChoiceController.LexemBeforeDropper, Nothing), ILexem)    If (lex.Text = "this") OrElse (lex.Text = "me") Then
       firstLevel = True
    Else If ContextChoiceListPresenceCheck(contextChoiceListLevelOne, lex.Text) = True Then
       secondLevel = True
    Else
       e.Cancel = True
    End If
End Sub
Private Sub editControl1_ContextChoiceOpen(ByVal controller As Syncfusion.Windows.Forms.Edit.Interfaces.IContextChoiceController) Handles editControl1.ContextChoiceOpen
    If firstLevel = True Then
       controller.Items.Clear()
    Dim i As Integer=0
    Do While i < contextChoiceListLevelOne.Length
         controller.Items.Add(contextChoiceListLevelOne(i), "This is a" & contextChoiceListLevelOne(i),          Me.editControl1.ContextChoiceController.Images(i))
         i += 1
         Loop
         ElseIf secondLevel = True Then
             controller.Items.Clear()
             Dim i As Integer=0
             Do While i < contextChoiceListLevelOne.Length
                  controller.Items.Add(contextChoiceListLevelTwo(i), "This is a" & contextChoiceListLevelTwo(i), Me.editControl1.ContextChoiceController.Images(i))
                  i += 1
                  Loop
          End If
          firstLevel = False
          secondLevel = False
End Sub

 

Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/intellisense#populate-intellisense-pop-up

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied